http 통신에서 ssl 우회해서 이미지 저장
This commit is contained in:
parent
f90a4a59b7
commit
92124475ce
@ -10,6 +10,7 @@ import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -72,6 +73,11 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -1495,12 +1501,25 @@ public class EstimateService {
|
||||
|
||||
estimateResponse.setPwrGnrSim(pwrGnrSimResponse);
|
||||
|
||||
//SSL 무시하기
|
||||
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {return null;}
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
|
||||
} };
|
||||
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection
|
||||
.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
//end
|
||||
|
||||
// 도면 이미지 셋팅
|
||||
String baseDrawingImgName = estimateRequest.getObjectNo() + "_" + estimateRequest.getPlanNo();
|
||||
|
||||
URL url = new URL(drawingDirPath + File.separator + baseDrawingImgName + "_1.png");
|
||||
URLConnection con = url.openConnection();
|
||||
HttpURLConnection exitCode = (HttpURLConnection)con;
|
||||
HttpURLConnection exitCode = (HttpURLConnection) con;
|
||||
if (exitCode.getResponseCode() == 200) {
|
||||
InputStream imageInputStream =
|
||||
new URL(drawingDirPath + File.separator + baseDrawingImgName + "_1.png").openStream();
|
||||
@ -1517,7 +1536,7 @@ public class EstimateService {
|
||||
String baseDrawingImgName2 = estimateRequest.getObjectNo() + "_" + estimateRequest.getPlanNo();
|
||||
URL url2 = new URL(drawingDirPath + File.separator + baseDrawingImgName2 + "_2.png");
|
||||
URLConnection con2 = url2.openConnection();
|
||||
HttpURLConnection exitCode2 = (HttpURLConnection)con2;
|
||||
HttpURLConnection exitCode2 = (HttpURLConnection) con2;
|
||||
if (exitCode2.getResponseCode() == 200) {
|
||||
InputStream imageInputStream2 =
|
||||
new URL(drawingDirPath + File.separator + baseDrawingImgName2 + "_2.png").openStream();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user