javax.net.ssl.SSLHandshakeException: No appropriate protocol報錯解決
一、問題描述
用java開發了一個簡單的發送郵件的程序,本地運行正常,但是上傳到服務器就出現報錯
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
二、問題解決
1、找到jdk目錄/jre/lib/security/java.security,去掉jdk.tls.disabledAlgorithm中的SSLv3、TLSv1、TLSv1.1,參考https://blog.csdn.net/Wing_kin666/article/details/116449722
2、但是上面方法並沒有解決問題,還需要執行以下命令,才最終解決報錯,參考https://stackoverflow.com/questions/38205947/sslhandshakeexception-no-appropriate-protocol#
update-crypto-policies --set LEGACY