From 23f0aba0ed87f1a788b764c1cce16d8cca78871c Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期五, 22 三月 2024 17:48:21 +0800 Subject: [PATCH] 修复媒体节点端口初始化失败 --- src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java index a1b7f84..9c473a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java @@ -2,9 +2,8 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServer; +import com.genersoft.iot.vmp.utils.SSLSocketClientUtil; import okhttp3.*; import okhttp3.logging.HttpLoggingInterceptor; import org.jetbrains.annotations.NotNull; @@ -13,11 +12,10 @@ import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; +import javax.net.ssl.X509TrustManager; import java.io.IOException; import java.net.ConnectException; -import java.net.MalformedURLException; import java.net.SocketTimeoutException; -import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -61,6 +59,10 @@ // OkHttp閫茶娣诲姞鏀旀埅鍣╨oggingInterceptor httpClientBuilder.addInterceptor(logging); } + X509TrustManager manager = SSLSocketClientUtil.getX509TrustManager(); + // 璁剧疆ssl + httpClientBuilder.sslSocketFactory(SSLSocketClientUtil.getSocketFactory(manager), manager); + httpClientBuilder.hostnameVerifier(SSLSocketClientUtil.getHostnameVerifier());//蹇界暐鏍¢獙 client = httpClientBuilder.build(); } return client; @@ -68,7 +70,7 @@ } - public JSONObject sendGet(MediaServerItem mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) { + public JSONObject sendGet(MediaServer mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) { OkHttpClient client = getClient(); if (mediaServerItem == null) { @@ -153,7 +155,7 @@ return responseJSON; } - public JSONObject sendPost(MediaServerItem mediaServerItem, String url, + public JSONObject sendPost(MediaServer mediaServerItem, String url, JSONObject param, ZLMRESTfulUtils.RequestCallback callback, Integer readTimeOut) { OkHttpClient client = getClient(readTimeOut); @@ -242,12 +244,12 @@ return responseJSON; } - public JSONObject getInfo(MediaServerItem mediaServerItem, RequestCallback callback){ + public JSONObject getInfo(MediaServer mediaServerItem, RequestCallback callback){ Map<String, Object> param = new HashMap<>(); return sendGet(mediaServerItem, "api/record/info",param, callback); } - public JSONObject addTask(MediaServerItem mediaServerItem, String app, String stream, String startTime, + public JSONObject addTask(MediaServer mediaServerItem, String app, String stream, String startTime, String endTime, String callId, List<String> filePathList, String remoteHost) { JSONObject videoTaskInfoJSON = new JSONObject(); @@ -264,7 +266,7 @@ return sendPost(mediaServerItem, urlStr, videoTaskInfoJSON, null, 30); } - public JSONObject queryTaskList(MediaServerItem mediaServerItem, String app, String stream, String callId, + public JSONObject queryTaskList(MediaServer mediaServerItem, String app, String stream, String callId, String taskId, Boolean isEnd, String scheme) { Map<String, Object> param = new HashMap<>(); if (!ObjectUtils.isEmpty(app)) { -- Gitblit v1.8.0