解决java发邮件错误javax.net.ssl.SSLHandshakeException: No appropriate protocol

java发送邮件时报以下错误信息:
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher

Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: smtp.suixingpay.com, port: 465;
  nested exception is:
	javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2055)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
	at javax.mail.Service.connect(Service.java:364)
	at javax.mail.Service.connect(Service.java:245)

错误原因:

jdk版本问题

笔者使用的jdk版本为1.8.0_301

/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/jre/lib/security/java.security

java.security文件内容

jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
    DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
    include jdk.disabled.namedCurves

解决办法

办法一:删除掉java.security文件中的SSLv3, TLSv1, TLSv1.1

办法二:更换jdk版本

猜你喜欢

转载自blog.csdn.net/xingxincsdn/article/details/127979882