我在使用 Apache Commons Mail 连接到 SMTP 服务器时遇到问题。我已经尝试了所有方法,但我在网上唯一能找到的是 Java Mail。 这是我的错误:
Caused by: javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
我发现您可以使用 props.put("mail.smtp.ssl.trust", "smtp.gmail.com");
修复 Java Mail 上的问题,但是我无法在 Apache Commons 上使用等效命令。
最佳答案
如果您确实要连接到 Gmail,则不需要它。 Gmail 证书将受到默认信任存储的信任。如果您配置了非默认信任存储,请使用 InstallCert 将 Gmail 证书添加到该信任存储。程序。
关于java - 无法在 Apache Commons Mail 上将套接字转换为 TLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38310763/