일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 스프링
- 오라클월별데이터
- 오라클
- 오라클클라우드에 젠킨스 설치하기
- Spring Boot가 해결하려고 했던 문제
- 스프링과 스프링부트 차이점
- 자바 왕기초
- 오라클일별데이터
- 스프링 Ioc Container
- 자바기초
- 스프링 부트가 해결하려고 했던 문제
- 자바왕초보
- 자바 기초
- 세션
- 오라클주별데이터
- CSS
- 제이쿼리
- maven
- 스프링 Ioc
- 자바
- java
- jsp
- 스프링 구글차트로 기간별 현황 조회하기
- 스프링 제어역전
- 자바왕기초
- 썸머노트
- 스프링 구글차트
- 스프링 에러
- 오라클통계
- HTML
- Today
- Total
Just Do it
[스프링/STS] DEBUG SMTP: could not connect to host "smtp.naver.com", port: 465, response: -1 & javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) & javax.net.ssl.SSLException: Unsupp.. 본문
[스프링/STS] DEBUG SMTP: could not connect to host "smtp.naver.com", port: 465, response: -1 & javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) & javax.net.ssl.SSLException: Unsupp..
Seojoo21 2022. 3. 19. 20:14첫번째 에러:
DEBUG SMTP: could not connect to host "smtp.naver.com", port: 465, response: -1
개인 프로젝트 중 회원 가입 시 입력한 이메일 주소로 인증 번호를 보내주는 기능을 구현하고자 SMTP Server를 이용한 메일 전송 방법을 공부하고 마지막 테스트를 하던 중 아래와 같은 에러를 만났다.
DEBUG SMTP: EOF: [EOF]
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.naver.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.naver.com, port: 465, response: -1; message exception details (1) are:
Failed message 1:
DEBUG SMTP: could not connect to host "smtp.naver.com", port: 465, response: -1
알고보니 root-context.xml에 메일 설정을 위해 등록한 mailsender 빈에 네이버의 SMTP 서버포트가 잘못되어 있었다.
네이버의 SMTP 서버포트 번호는 465가 아닌 587이었고 또한 <props>에 추가로 SSL 설정을 해줘야만 했다.
<prop key="mail.smtp.ssl.enable">true</prop>
그래서 root-context.xml에서 빈 설정을 수정하였다.
* 수정 전)
* 수정 후)
그러나 또다른 에러가 발생했다....
두번째 에러:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
또 다른 에러가 발생했다. 포트번호를 587이 아닌 465로 해도 포트번호만 바뀔 뿐 동일한 에러가 나타났다.
이로써 먼저 등장했던 "DEBUG SMTP: could not connect to host "smtp.naver.com", port: 465, response: -1" 이 에러는 <props> 에 SSL 설정을 하지 않아 발생한 에러로 보였다.
javax.mail.MessagingException: Could not connect to SMTP host: smtp.naver.com, port: 587;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
javax.mail.MessagingException: Could not connect to SMTP host: smtp.naver.com, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
찾아보니...
-------------------------
위의 에러는 server와 client 간에 사용하는 SSL/TLS 버전이 맞지 않기 때문에 발생합니다.
server가 TLS 1.2 버전만 사용할 때 Java의 경우 JDK 1.8 부터 TLS 1.2 가 기본 버전이므로 문제가 없지만, 이전 JDK 버전을 사용하는 client의 경우는 예외가 발생하게 됩니다.
JDK 1.8 버전으로 업그레이드하면 문제가 해결되지만.... (생략)
(출처: https://freestrokes.tistory.com/68)
-----------------------------------------
엥....? JDK 1.8로 프로젝트를 하고 있는데 저 에러가 발생했다니 너무 당황스러웠다. 해결을 위해 구글링을 하던 중 스택오버플로우에서 아래 댓글을 보았는데...
읽어보니 pom.xml에 설정한 javax.mail 버전을 바꾸면 되는 것 같아서 시도해보았다.
그래서 기존 1.4.7 버전을 주석처리하고 1.6.2 버전을 넣어보았다. 이 과정에서 Maven 내에서 기존 javax 1.4.7 와 충돌하는지 콘솔창에 계속 오류가 뜨길래 STS 를 끄고 m2에서 repository를 모두 삭제한 후 다시 STS 켜서 Maven 업데이트를 해주었다.
그랬더니 또 다른 에러가 발생했다......
세번째 에러:
javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
세번째 에러는 다음과 같았다.
Failed message 1:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.naver.com, port: 587;
nested exception is:
javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
구글에 검색해보니 아래 글을 볼 수 있었다.
(출처: http://daplus.net/java-인식-할-수없는-ssl-메시지-일반-텍스트-연결-예외/)
올바른 포트 번호를 사용하지 않았을 것이라고 해서 포트번호를 587에서 처음 시도했던 465로 다시 변경해보았다.
그랬더니 마침내 해결 !!!!!!! 테스트 메일도 잘 들어왔다!!!
참고 사이트: https://okky.kr/article/1155391
https://www.lesstif.com/system-admin/java-sslhandshakeexception-29590407.html