WSO2 ESB - 发送电子邮件

时间:2016-07-27 10:13:40

标签: java javamail wso2esb

我有一个简单的电子邮件警报用例。

在axis2.xml中完成了基本配置,当我尝试代理时,会出现以下异常。

javax.mail.MessagingException: Can't send command to SMTP host;
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
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)

Caused by: 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

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)

TID: [-1234] [] [2016-07-27 14:19:30,758] ERROR
{org.apache.axis2.transport.mail.MailTransportSender} - Error creating mail message or sending it to the configured server {org.apache.axis2.transport.mail.MailTransportSender}

javax.mail.MessagingException: Can't send command to SMTP host;
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
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)

问题是,我相信我在ESB的配置中缺少以下代码行。

Session session = Session.getInstance(props,
                new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("aaa", "bbb@0089");
                    }
                });

我尝试过使用小型java电子邮件应用程序和javamailAPI成功测试,包括此身份验证。

如何在<ESB_HOME>/repository/conf/axis2/axis2.xml

中执行相同的配置

任何建议都会非常有用。 ESB 4.9.0

提前致谢。

1 个答案:

答案 0 :(得分:0)

这似乎是因为客户端信任库中没有所需的证书。导入后再试一次。要将证书导入信任库,您可以参考此blog