File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
lib_common/src/main/java/com/guiying/common/http Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 2626import java .security .cert .X509Certificate ;
2727
2828import javax .net .ssl .HostnameVerifier ;
29+ import javax .net .ssl .HttpsURLConnection ;
2930import javax .net .ssl .KeyManagerFactory ;
3031import javax .net .ssl .SSLContext ;
3132import javax .net .ssl .SSLSession ;
@@ -125,13 +126,18 @@ public static SSLParams getSslSocketFactoryUnsafe() {
125126
126127
127128 /**
128- * 主机名校验方法
129+ * 主机名校验方法,请把”192.168.0.10”换成你们公司的主机IP:
129130 */
130131 public static HostnameVerifier getHostnameVerifier () {
131132 return new HostnameVerifier () {
132133 @ Override
133134 public boolean verify (String hostname , SSLSession session ) {
134- return hostname .equalsIgnoreCase (session .getPeerHost ());
135+ if ("192.168.0.10" .equals (hostname )) {
136+ return true ;
137+ } else {
138+ HostnameVerifier hv = HttpsURLConnection .getDefaultHostnameVerifier ();
139+ return hv .verify (hostname , session );
140+ }
135141 }
136142 };
137143 }
You can’t perform that action at this time.
0 commit comments