[英]SunCertPathBuilderException: unable to find valid certification path to requested target`
I know there are a lot of question regarding the same thing on SO, but I don't seem to have found the solution for my problem yet. 我知道在SO上有很多关于同样事情的问题,但我似乎还没有为我的问题找到解决方案。
I am using JavaMail API to connect to a mail server. 我正在使用JavaMail API连接到邮件服务器。 Initially I used the port 110 to connect to pop3 server and that is when I got the following exception - 最初我使用端口110连接到pop3服务器,那时我得到以下异常 -
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
I changed the port to 995 and got the following exception - 我将端口更改为995并获得以下异常 -
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Code for connecting to the server : 连接服务器的代码 :
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "pop3");
props.setProperty("mail.pop3.ssl.enable", "true");
Session session = Session.getInstance(props, null);
store = session.getStore("pop3");
store.connect(ServerName, Port, UserName, Password);
Where am I going wrong? 我哪里错了? Any advice would be helpful. 任何意见将是有益的。 Thanks in advance. 提前致谢。
The first error message says it all. 第一条错误消息说明了一切。 You're attempting SSL to a plaintext port. 您正在尝试SSL到明文端口。 Try disabling SSL, or use the correct port for SSL. 尝试禁用SSL,或使用正确的SSL端口。
The second one says that your truststore doesn't trust the server certificate. 第二个说您的信任库不信任服务器证书。 If it's self-signed, you will need to import it into your truststore. 如果它是自签名的,您需要将其导入您的信任库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.