Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java SSLPeerUnverifiedException #52

Open
raycon opened this issue Jan 10, 2021 · 0 comments
Open

Java SSLPeerUnverifiedException #52

raycon opened this issue Jan 10, 2021 · 0 comments

Comments

@raycon
Copy link
Owner

raycon commented Jan 10, 2021

JAVA 에서 다음과 같은 오류가 발생하는 경우

java.lang.IllegalStateException: javax.net.ssl.SSLPeerUnverifiedException:
   Certificate for <a.host.com> doesn't match any of the subject
   alternative names: [b.host.com]

https://a.host.com 으로 접속하려고 하는데 인증서가 https://b.host.com으로 발급되어 있는 경우다. 개발시에 접속이 필요할 경우 다음과 같이 설정할 수 있다.

HttpClientBuilder builder = HttpClientBuilder.create();
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
    SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(),
    NoopHostnameVerifier.INSTANCE);
builder.setSSLSocketFactory(scsf);
builder.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant