This commit is contained in:
2025-08-20 01:23:26 +08:00
parent 65cca681ef
commit 44b7a7bfd2
2 changed files with 4 additions and 5 deletions

View File

@@ -226,7 +226,8 @@ public class HttpUtils
try try
{ {
log.info("sendSSLPost - {}", urlNameString); log.info("sendSSLPost - {}", urlNameString);
SSLContext sc = SSLContext.getInstance("SSL"); // 使用 TLSv1.2 提升与现代 HTTPS 服务的兼容性
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom()); sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
URL console = new URL(urlNameString); URL console = new URL(urlNameString);
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection(); HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();

View File

@@ -87,10 +87,8 @@ public abstract class ERPRequestBase {
System.out.println("请求地址: " + requestUrl); System.out.println("请求地址: " + requestUrl);
System.out.println("请求体: " + body); System.out.println("请求体: " + body);
if (requestBody == null) { // 统一通过自定义 SSL 通道发起请求,提升与开放平台的 TLS 兼容性
return HttpUtils.sendPost(requestUrl, body); // 保持 body 一致 return HttpUtils.sendSSLPost(requestUrl, body, org.springframework.http.MediaType.APPLICATION_JSON_VALUE);
}
return HttpUtils.sendJsonPost(requestUrl, body);
} catch (Exception e) { } catch (Exception e) {
log.error("HTTP请求失败: {}", e.getMessage(), e); log.error("HTTP请求失败: {}", e.getMessage(), e);
throw new RuntimeException("ERP接口调用失败: " + e.getMessage(), e); throw new RuntimeException("ERP接口调用失败: " + e.getMessage(), e);