java.security.cert.CertificateException:No subject alternative names matching IP address xxx.xxx.xxx.xxx found; nested exception is
javax.net.ssl.SSLHandshakeException java.security.cert.CertificateException: No subject alternative names matching IP address xxx.xxx.xxx.xxx found
로컬에서 https로 호출했을 경우 발생 !
static {
disableSslVerification();
}
private static void disableSslVerification() {
try
{
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}
};
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// Create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
}
호출하는 class내에 복붙,
**로컬에서 테스트용으로 단지 sslException을 막는 방식임
'개발 > Error' 카테고리의 다른 글
[Maven] 메이븐 패키징 실패 (0) | 2020.10.22 |
---|