Commit 4863ed06 authored by CaptainB's avatar CaptainB Committed by 刘瑞斌
Browse files

fix: 校验url时忽略ssl

parent d73ee56f
Showing with 7 additions and 0 deletions
+7 -0
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();// 请求状态
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment