okhttp3.Handshake.tlsVersion()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中okhttp3.Handshake.tlsVersion()方法的一些代码示例,展示了Handshake.tlsVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handshake.tlsVersion()方法的具体详情如下:
包路径:okhttp3.Handshake
类名称:Handshake
方法名:tlsVersion

Handshake.tlsVersion介绍

[英]Returns the TLS version used for this connection. May return null if the response was cached with a version of OkHttp prior to 3.0.
[中]返回用于此连接的TLS版本。如果响应是使用OkHttp 3.0之前的版本缓存的,则可能返回null。

代码示例

代码示例来源:origin: square/okhttp

/** Returns the connection's TLS version or null if the connection doesn't use SSL. */
public TlsVersion getTlsVersion() {
 return handshake != null ? handshake.tlsVersion() : null;
}

代码示例来源:origin: square/okhttp

private static void sendRequest(OkHttpClient client, String url) {
  System.out.printf("%-40s ", url);
  System.out.flush();

  System.out.println(Platform.get());

  Request request = new Request.Builder().url(url).build();

  try (Response response = client.newCall(request).execute()) {
   Handshake handshake = response.handshake();
   System.out.println(handshake.tlsVersion()
     + " "
     + handshake.cipherSuite()
     + " "
     + response.protocol()
     + " "
     + response.code
     + " "
     + response.body.bytes().length
     + "b");
  } catch (IOException ioe) {
   System.out.println(ioe.toString());
  }
 }
}

代码示例来源:origin: square/okhttp

public void run() throws Exception {
 String localhost = InetAddress.getByName("localhost").getCanonicalHostName();
 HeldCertificate localhostCertificate = new HeldCertificate.Builder()
   .addSubjectAlternativeName(localhost)
   .build();
 HandshakeCertificates serverCertificates = new HandshakeCertificates.Builder()
   .heldCertificate(localhostCertificate)
   .build();
 MockWebServer server = new MockWebServer();
 server.useHttps(serverCertificates.sslSocketFactory(), false);
 server.enqueue(new MockResponse());
 HandshakeCertificates clientCertificates = new HandshakeCertificates.Builder()
   .addTrustedCertificate(localhostCertificate.certificate())
   .build();
 OkHttpClient client = new OkHttpClient.Builder()
   .sslSocketFactory(clientCertificates.sslSocketFactory(), clientCertificates.trustManager())
   .build();
 Call call = client.newCall(new Request.Builder()
   .url(server.url("/"))
   .build());
 Response response = call.execute();
 System.out.println(response.handshake().tlsVersion());
}

代码示例来源:origin: square/okhttp

writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');

代码示例来源:origin: apollographql/apollo-android

writeCertList(bufferedSink, handshake.localCertificates());
if (handshake.tlsVersion() != null) {
 bufferedSink.writeUtf8(handshake.tlsVersion().javaName())
   .writeByte('\n');

代码示例来源:origin: com.squareup.okhttp3/okhttp

writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');

代码示例来源:origin: duzechao/OKHttpUtils

writeCertList(sink, handshake.localCertificates());
if (handshake.tlsVersion() != null) {
 sink.writeUtf8(handshake.tlsVersion().javaName());
 sink.writeByte('\n');

代码示例来源:origin: com.github.ljun20160606/okhttp

writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');

代码示例来源:origin: apache/servicemix-bundles

writeCertList(sink, handshake.peerCertificates());
writeCertList(sink, handshake.localCertificates());
sink.writeUtf8(handshake.tlsVersion().javaName()).writeByte('\n');

相关文章