File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
okhttp/src/main/java/okhttp3 Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -648,13 +648,8 @@ public Builder socketFactory(SocketFactory socketFactory) {
648
648
*/
649
649
public Builder sslSocketFactory (SSLSocketFactory sslSocketFactory ) {
650
650
if (sslSocketFactory == null ) throw new NullPointerException ("sslSocketFactory == null" );
651
- X509TrustManager trustManager = Platform .get ().trustManager (sslSocketFactory );
652
- if (trustManager == null ) {
653
- throw new IllegalStateException ("Unable to extract the trust manager on " + Platform .get ()
654
- + ", sslSocketFactory is " + sslSocketFactory .getClass ());
655
- }
656
651
this .sslSocketFactory = sslSocketFactory ;
657
- this .certificateChainCleaner = CertificateChainCleaner .get (trustManager );
652
+ this .certificateChainCleaner = Platform .get (). buildCertificateChainCleaner ( sslSocketFactory );
658
653
return this ;
659
654
}
660
655
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ class AndroidPlatform extends Platform {
79
79
}
80
80
}
81
81
82
- @ Override public X509TrustManager trustManager (SSLSocketFactory sslSocketFactory ) {
82
+ @ Override protected X509TrustManager trustManager (SSLSocketFactory sslSocketFactory ) {
83
83
Object context = readFieldOrNull (sslSocketFactory , sslParametersClass , "sslParameters" );
84
84
if (context == null ) {
85
85
// If that didn't work, try the Google Play Services SSL provider before giving up. This
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public String getPrefix() {
85
85
return "OkHttp" ;
86
86
}
87
87
88
- public X509TrustManager trustManager (SSLSocketFactory sslSocketFactory ) {
88
+ protected X509TrustManager trustManager (SSLSocketFactory sslSocketFactory ) {
89
89
// Attempt to get the trust manager from an OpenJDK socket factory. We attempt this on all
90
90
// platforms in order to support Robolectric, which mixes classes from both Android and the
91
91
// Oracle JDK. Note that we don't support HTTP/2 or other nice features on Robolectric.
@@ -168,6 +168,17 @@ public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager tru
168
168
return new BasicCertificateChainCleaner (buildTrustRootIndex (trustManager ));
169
169
}
170
170
171
+ public CertificateChainCleaner buildCertificateChainCleaner (SSLSocketFactory sslSocketFactory ) {
172
+ X509TrustManager trustManager = trustManager (sslSocketFactory );
173
+
174
+ if (trustManager == null ) {
175
+ throw new IllegalStateException ("Unable to extract the trust manager on " + Platform .get ()
176
+ + ", sslSocketFactory is " + sslSocketFactory .getClass ());
177
+ }
178
+
179
+ return buildCertificateChainCleaner (trustManager );
180
+ }
181
+
171
182
/** Attempt to match the host runtime to a capable Platform implementation. */
172
183
private static Platform findPlatform () {
173
184
Platform android = AndroidPlatform .buildIfSupported ();
You can’t perform that action at this time.
0 commit comments