diff --git a/backend/src/main/java/io/metersphere/commons/utils/UrlTestUtils.java b/backend/src/main/java/io/metersphere/commons/utils/UrlTestUtils.java index a118828a0f..f0458a77dd 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/UrlTestUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/UrlTestUtils.java @@ -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();// 请求状态