Converts an instance of com.squareup.okhttp.ConnectionSpec for a secure connection into that of ConnectionSpec in the current package. @throws IllegalArgumentException If spec is not with TLS
(com.squareup.okhttp.ConnectionSpec spec)
| 72 | * If {@code spec} is not with TLS |
| 73 | */ |
| 74 | static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) { |
| 75 | Preconditions.checkArgument(spec.isTls(), "plaintext ConnectionSpec is not accepted"); |
| 76 | |
| 77 | List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions(); |
| 78 | String[] tlsVersions = new String[tlsVersionList.size()]; |
| 79 | for (int i = 0; i < tlsVersions.length; i++) { |
| 80 | tlsVersions[i] = tlsVersionList.get(i).javaName(); |
| 81 | } |
| 82 | |
| 83 | List<com.squareup.okhttp.CipherSuite> cipherSuiteList = spec.cipherSuites(); |
| 84 | CipherSuite[] cipherSuites = new CipherSuite[cipherSuiteList.size()]; |
| 85 | for (int i = 0; i < cipherSuites.length; i++) { |
| 86 | cipherSuites[i] = CipherSuite.valueOf(cipherSuiteList.get(i).name()); |
| 87 | } |
| 88 | |
| 89 | return new ConnectionSpec.Builder(spec.isTls()) |
| 90 | .supportsTlsExtensions(spec.supportsTlsExtensions()) |
| 91 | .tlsVersions(tlsVersions) |
| 92 | .cipherSuites(cipherSuites) |
| 93 | .build(); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Attempts to capture all known socket options and return the results as a |