How to disable javamail SSL support?

天涯浪子 提交于 2019-12-11 13:46:56

问题


I receive the following Exception while trying to send an email (using Seam)

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find vali
d certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
        at sun.security.validator.Validator.validate(Validator.java:218)
        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
        ... 68 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
        ... 74 more

I tested the server by using a plain javamail app with no extra settings and it worked fine.

But using Seams mail-tags the Exception occurs. - Is there a way to disable SSL? I realy don't need SSL.

I found these properties in a forum

mail.smtp.ssl.trust="*"
mail.smtp.starttls.enable="true"
  • How could I pass them the properties above through seam framework down to javamail ?

回答1:


According to Seam reference manual and Seam forum you should be able to disable TLS and SSL directly in your components.xml configuration:

<mail:mail-session debug="true" tls="false" ssl="false" ... />



回答2:


The error you're getting means that one of the certificates (presumably the server's certificate) isn't trusted by your JavaMail client. Since you seem to be using STARTTLS, you're effectively using SSL/TLS.

You could perhaps try something like mail.smtp.starttls.enable="false" if you don't want to use SSL/TLS at all, although some SMTP servers will force you to use it (either SSL/TLS on connection or via STARTTLS) to proceed any further.

Alternatively, if you change your mind and want/need to use SSL, make sure your trust store on the client side contains a trust anchor (CA certificate) that can be used to verify your server certificate. (Note that the mail.smtp.ssl.checkserveridentity default to false is insecure, so you'd want to change that to true, and not use mail.smtp.ssl.trust="*".)



来源:https://stackoverflow.com/questions/4237970/how-to-disable-javamail-ssl-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!