Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

뇌약간고침

[SMTP] javax.mail.MessagingException: Could not connect to SMTP host, port 본문

Study/Spring

[SMTP] javax.mail.MessagingException: Could not connect to SMTP host, port

minulbora 2024. 3. 4. 17:51
 Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171) ~[?:1.8.0_332] at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:103) ~[?:1.8.0_332] at sun.security.ssl.TransportContext.kickstart(TransportContext.java:220) ~[?:1.8.0_332] at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:433) ~[?:1.8.0_332] at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:549) ~[mail-1.4.7.jar:1.4.7] at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:354) ~[mail-1.4.7.jar:1.4.7] at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237) ~[mail-1.4.7.jar:1.4.7] at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927) ~[mail-1.4.7.jar:1.4.7] ... 52 more

프로토콜의 버전이 맞지 않다고한다. 

나는 자바 1.8.0 쓰고 있고 프로퍼티에도 아래처럼 ssl 프로토콜을 추가했는데... 도대체 왜 안되는걸까. 

Properties props = new Properties();
props.setProperty("mail.smtp.ssl.enable", "true");
props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.ssl.protocol","TLSv1.2");

시스템에도 추가함.

System.setProperty("jdk.tls.client.protocols", "TLSv1.2");

안됨. 

보안 제공자 문제일 수도 있다고 해서 Sequrity도 추가함

Security.setProperty("ssl.SocketFactory.provider", "com.sun.net.ssl.internal.ssl.Provider");
Security.setProperty("ssl.ServerSocketFactory.provider", "com.sun.net.ssl.internal.ssl.Provider");

안됨.

아무래도 직접 자바홈 열어서 수정해야 할 것 같다. 

https://blog.naver.com/moonv11/221417147616

 

java.security 파일에 대한 고찰

다음과 같은 에러가 발생한다면 Java 에서 사용하는 TLS 알고리즘과 서버에서 사용하는 인증서 버전이 ...

blog.naver.com

수정해도 안됨.

 

결론: pom.xml 버전 맞추니 해결