简体   繁体   English

如何禁用javamail SSL支持?

[英]How to disable javamail SSL support?

I receive the following Exception while trying to send an email (using Seam) 尝试发送电子邮件(使用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. 我使用无附加设置的普通javamail应用程序测试了服务器,并且运行良好。

But using Seams mail-tags the Exception occurs. 但是使用Seams邮件标签会发生异常。 - Is there a way to disable SSL? -有禁用SSL的方法吗? I realy don't need SSL. 我真的不需要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 ? 我如何通过接缝框架将它们上面的属性传递给javamail?

The error you're getting means that one of the certificates (presumably the server's certificate) isn't trusted by your JavaMail client. 您得到的错误意味着JavaMail客户端不信任其中一个证书(可能是服务器的证书)。 Since you seem to be using STARTTLS, you're effectively using SSL/TLS. 由于您似乎正在使用STARTTLS,因此实际上是在使用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. 如果您根本不想使用SSL / TLS,则可以尝试使用mail.smtp.starttls.enable="false" ,尽管某些SMTP服务器会强制您使用它(连接时使用SSL / TLS或通过STARTTLS)继续。

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. 或者,如果您改变主意并希望/需要使用SSL,请确保客户端上的信任库包含可用于验证服务器证书的信任锚(CA证书)。 (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="*" .) (请注意,默认为falsemail.smtp.ssl.checkserveridentity不安全,因此您希望将其更改为true ,而不要使用mail.smtp.ssl.trust="*" 。)

根据Seam参考手册Seam论坛,您应该能够直接在components.xml配置中禁用TLS和SSL:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM