1
This commit is contained in:
@@ -226,7 +226,8 @@ public class HttpUtils
|
||||
try
|
||||
{
|
||||
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());
|
||||
URL console = new URL(urlNameString);
|
||||
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
|
||||
|
||||
@@ -87,10 +87,8 @@ public abstract class ERPRequestBase {
|
||||
System.out.println("请求地址: " + requestUrl);
|
||||
System.out.println("请求体: " + body);
|
||||
|
||||
if (requestBody == null) {
|
||||
return HttpUtils.sendPost(requestUrl, body); // 保持 body 一致
|
||||
}
|
||||
return HttpUtils.sendJsonPost(requestUrl, body);
|
||||
// 统一通过自定义 SSL 通道发起请求,提升与开放平台的 TLS 兼容性
|
||||
return HttpUtils.sendSSLPost(requestUrl, body, org.springframework.http.MediaType.APPLICATION_JSON_VALUE);
|
||||
} catch (Exception e) {
|
||||
log.error("HTTP请求失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("ERP接口调用失败: " + e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user