fix: 校验url时忽略ssl
This commit is contained in:
parent
d73ee56f94
commit
4863ed0682
|
@ -1,5 +1,8 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import io.metersphere.ldap.service.CustomSSLSocketFactory;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -9,6 +12,10 @@ public class UrlTestUtils {
|
|||
try {
|
||||
URL urlObj = new URL(address);
|
||||
HttpURLConnection oc = (HttpURLConnection) urlObj.openConnection();
|
||||
if (oc instanceof HttpsURLConnection) {
|
||||
((HttpsURLConnection) oc).setSSLSocketFactory(new CustomSSLSocketFactory());
|
||||
((HttpsURLConnection) oc).setHostnameVerifier((hostname, session) -> true);
|
||||
}
|
||||
oc.setUseCaches(false);
|
||||
oc.setConnectTimeout(timeOutMillSeconds); // 设置超时时间
|
||||
int status = oc.getResponseCode();// 请求状态
|
||||
|
|
Loading…
Reference in New Issue