本文整理了Java中okhttp3.Handshake.peerCertificates()
方法的一些代码示例,展示了Handshake.peerCertificates()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handshake.peerCertificates()
方法的具体详情如下:
包路径:okhttp3.Handshake
类名称:Handshake
方法名:peerCertificates
[英]Returns a possibly-empty list of certificates that identify the remote peer.
[中]返回标识远程对等方的证书的可能为空的列表。
代码示例来源:origin: square/okhttp
@Override
public List<Certificate> getServerCertificateChain() throws SSLPeerUnverifiedException {
if (handshake == null) return null;
// Java requires null, not an empty list here.
List<Certificate> certificates = handshake.peerCertificates();
return certificates.size() > 0 ? certificates : null;
}
代码示例来源:origin: square/okhttp
@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
Handshake handshake = handshake();
if (handshake == null) return null;
List<Certificate> result = handshake.peerCertificates();
return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null;
}
代码示例来源:origin: square/okhttp
public void run() throws Exception {
Request request = new Request.Builder()
.url("https://publicobject.com/robots.txt")
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
for (Certificate certificate : response.handshake().peerCertificates()) {
System.out.println(CertificatePinner.pin(certificate));
}
}
}
代码示例来源:origin: square/okhttp
@Override public Response intercept(Chain chain) throws IOException {
for (Certificate certificate : chain.connection().handshake().peerCertificates()) {
String pin = CertificatePinner.pin(certificate);
if (blacklist.contains(pin)) {
throw new IOException("Blacklisted peer certificate: " + pin);
}
}
return chain.proceed(chain.request());
}
};
代码示例来源:origin: square/okhttp
public boolean supportsUrl(HttpUrl url) {
if (url.port() != route.address().url().port()) {
return false; // Port mismatch.
}
if (!url.host().equals(route.address().url().host())) {
// We have a host mismatch. But if the certificate matches, we're still good.
return handshake != null && OkHostnameVerifier.INSTANCE.verify(
url.host(), (X509Certificate) handshake.peerCertificates().get(0));
}
return true; // Success. The URL is supported.
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
public boolean supportsUrl(HttpUrl url) {
if (url.port() != route.address().url().port()) {
return false; // Port mismatch.
}
if (!url.host().equals(route.address().url().host())) {
// We have a host mismatch. But if the certificate matches, we're still good.
return handshake != null && OkHostnameVerifier.INSTANCE.verify(
url.host(), (X509Certificate) handshake.peerCertificates().get(0));
}
return true; // Success. The URL is supported.
}
代码示例来源:origin: square/okhttp
List<Certificate> peerCertificates = unverifiedHandshake.peerCertificates();
if (!peerCertificates.isEmpty()) {
X509Certificate cert = (X509Certificate) peerCertificates.get(0);
unverifiedHandshake.peerCertificates());
代码示例来源:origin: square/okhttp
address.certificatePinner().check(address.url().host(), handshake().peerCertificates());
} catch (SSLPeerUnverifiedException e) {
return false;
代码示例来源:origin: com.squareup.okhttp3/okhttp
List<Certificate> peerCertificates = unverifiedHandshake.peerCertificates();
if (!peerCertificates.isEmpty()) {
X509Certificate cert = (X509Certificate) peerCertificates.get(0);
unverifiedHandshake.peerCertificates());
代码示例来源:origin: com.squareup.okhttp3/okhttp
address.certificatePinner().check(address.url().host(), handshake().peerCertificates());
} catch (SSLPeerUnverifiedException e) {
return false;
代码示例来源:origin: square/okhttp
sink.writeUtf8(handshake.cipherSuite().javaName())
.writeByte('\n');
writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');
代码示例来源:origin: com.squareup.okhttp3/okhttp
sink.writeUtf8(handshake.cipherSuite().javaName())
.writeByte('\n');
writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');
代码示例来源:origin: apollographql/apollo-android
bufferedSink.writeUtf8(handshake.cipherSuite().javaName())
.writeByte('\n');
writeCertList(bufferedSink, handshake.peerCertificates());
writeCertList(bufferedSink, handshake.localCertificates());
代码示例来源:origin: com.squareup.okhttp3/okhttp-android-support
@Override
public List<Certificate> getServerCertificateChain() throws SSLPeerUnverifiedException {
if (handshake == null) return null;
// Java requires null, not an empty list here.
List<Certificate> certificates = handshake.peerCertificates();
return certificates.size() > 0 ? certificates : null;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp-urlconnection
@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
Handshake handshake = handshake();
if (handshake == null) return null;
List<Certificate> result = handshake.peerCertificates();
return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null;
}
代码示例来源:origin: com.github.ljun20160606/okhttp-urlconnection
@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
Handshake handshake = handshake();
if (handshake == null) return null;
List<Certificate> result = handshake.peerCertificates();
return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null;
}
代码示例来源:origin: apache/servicemix-bundles
@Override public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
Handshake handshake = handshake();
if (handshake == null) return null;
List<Certificate> result = handshake.peerCertificates();
return !result.isEmpty() ? result.toArray(new Certificate[result.size()]) : null;
}
代码示例来源:origin: com.github.ljun20160606/okhttp
public boolean supportsUrl(HttpUrl url) {
if (url.port() != route.address().url().port()) {
return false; // Port mismatch.
}
if (!url.host().equals(route.address().url().host())) {
// We have a host mismatch. But if the certificate matches, we're still good.
return handshake != null && OkHostnameVerifier.INSTANCE.verify(
url.host(), (X509Certificate) handshake.peerCertificates().get(0));
}
return true; // Success. The URL is supported.
}
代码示例来源:origin: apache/servicemix-bundles
public boolean supportsUrl(HttpUrl url) {
if (url.port() != route.address().url().port()) {
return false; // Port mismatch.
}
if (!url.host().equals(route.address().url().host())) {
// We have a host mismatch. But if the certificate matches, we're still good.
return handshake != null && OkHostnameVerifier.INSTANCE.verify(
url.host(), (X509Certificate) handshake.peerCertificates().get(0));
}
return true; // Success. The URL is supported.
}
代码示例来源:origin: huxq17/SwipeCardsView
sink.writeUtf8(handshake.cipherSuite().javaName());
sink.writeByte('\n');
writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
内容来源于网络,如有侵权,请联系作者删除!