File tree 1 file changed +11
-5
lines changed
src/main/java/com/ning/http/client 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 25
25
26
26
import javax .net .ssl .HostnameVerifier ;
27
27
import javax .net .ssl .SSLContext ;
28
+ import javax .net .ssl .SSLSession ;
28
29
29
30
import java .util .Collections ;
30
31
import java .util .LinkedList ;
@@ -385,10 +386,15 @@ public boolean isValid() {
385
386
* @return the {@link HostnameVerifier}
386
387
*/
387
388
public HostnameVerifier getHostnameVerifier () {
388
- if (hostnameVerifier == null && ! acceptAnyCertificate ) {
389
- synchronized (this ) {
389
+ if (hostnameVerifier == null ) {
390
+ synchronized (this ) {
390
391
if (hostnameVerifier == null )
391
- hostnameVerifier = new DefaultHostnameVerifier ();
392
+ hostnameVerifier = acceptAnyCertificate ? new HostnameVerifier () {
393
+ @ Override
394
+ public boolean verify (String hostname , SSLSession session ) {
395
+ return true ;
396
+ }
397
+ } : new DefaultHostnameVerifier ();
392
398
}
393
399
}
394
400
return hostnameVerifier ;
@@ -926,12 +932,12 @@ public Builder setSslSessionCacheSize(Integer sslSessionCacheSize) {
926
932
this .sslSessionCacheSize = sslSessionCacheSize ;
927
933
return this ;
928
934
}
929
-
935
+
930
936
public Builder setSslSessionTimeout (Integer sslSessionTimeout ) {
931
937
this .sslSessionTimeout = sslSessionTimeout ;
932
938
return this ;
933
939
}
934
-
940
+
935
941
/**
936
942
* Create a config builder with values taken from the given prototype configuration.
937
943
*
You can’t perform that action at this time.
0 commit comments