From 4863ed06823282227a5d13661cdbe2172d4eb739 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 30 Dec 2021 12:25:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8Curl=E6=97=B6=E5=BF=BD?= =?UTF-8?q?=E7=95=A5ssl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/commons/utils/UrlTestUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) 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();// 请求状态