简体   繁体   English

javax.mail.MessagingException:无法将命令发送到SMTP主机;

[英]javax.mail.MessagingException: Can't send command to SMTP host;

I have imported the certificate to cacerts (to where the JAVA_HOME is pointing) but still getting this error. 我已将证书导入到cacerts(JAVA_HOME指向的位置),但仍然收到此错误。 Not able to figure out the issue. 无法找出问题。 There is no firewall issue from client's mail server which is a Microsoft ESMTP server. 客户端的邮件服务器(Microsoft ESMTP服务器)没有防火墙问题。 I am able to telnet this from my server. 我可以通过服务器远程登录。 Tried SSLpoke but it's getting timed out. 尝试过SSLpoke,但它已超时。 Tried tcpdump of port 25, can see the communication back and forth. 尝试了25端口的tcpdump,可以看到来回通信。 Basically trying to a trigger an outbound email from the mail server. 基本上是尝试触发来自邮件服务器的出站电子邮件。

The detailed error log is: 详细的错误日志为:

Caused by: javax.mail.MessagingException: Can't send command to SMTP host; 原因:javax.mail.MessagingException:无法将命令发送到SMTP主机。 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) at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384) at javax.mail.Service.connect(Service.java:297) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at com.issuetracker.esb.mail.GmailImpl.transportMessage(GmailImpl.java:94) at com.issuetracker.esb.mail.Mail.sendSRMail(Mail.java:188) 嵌套的异常是:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法在com.sun.mail上找到请求的目标的有效证书路径。 com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)(位于com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847)处的.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420) )的com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384)的javax.mail.Service.connect(Service.java:297)的javax.mail.Service.connect(Service.java:156)的在com.issuetracker的javax.mail.Transport.send0(Transport.java:168)的javax.mail.Service.connect(Service.java:105)处。 esb.mail.GmailImpl.transportMessage(GmailImpl.java:94)位于com.issuetracker.esb.mail.Mail.sendSRMail(Mail.java:188)

Did you use the -trustcacerts parameter when importing the cert with keytool? 使用keytool导入证书时是否使用-trustcacerts参数?

Edit: My conversation on this topic has covered specific reasons for the error to occur but did not have the appearance of an 'answer', so here's a rewrite. 编辑:我在这个话题上的谈话已经涵盖了发生错误的具体原因,但没有出现“答案”的外观,因此这里是一个重写。

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到到请求目标的有效认证路径

This error indicates that a valid certificate chain for the purposes of trusting an incoming certificate could not be obtained from the resident keystore file being used by the running JRE (by default, in the JRE's jre/lib/security/cacerts file). 此错误表明,无法从正在运行的JRE使用的驻留密钥库文件中获得用于信任传入证书的有效证书链(默认情况下,在JRE的jre / lib / security / cacerts文件中)。

Typical causes of this include: 造成这种情况的典型原因包括:

Neglecting to include the parameter -trustcacerts when importing the certificate with the keytool command. 使用keytool命令导入证书时,忽略包含-trustcacerts参数。

When the JRE is looking for certificates it knows about to match the incoming one, it will only consider the certificates that have been marked as trusted in this way. 当JRE寻找它知道要与传入证书匹配的证书时,它将仅考虑以这种方式标记为受信任的证书。

The certificate has been signed by a root CA for whom the JRE does not already have the root certificate installed for. 该证书已由根CA签署,该根CA尚未为其安装JRE的根证书。

Typically this is caused by having the certificate signed by an unknown root certificate authority (CA), such as a company's own internal CA that the JRE knows nothing about (yet), or even by some third party root CAs that aren't as popular as some other big-name vendors, and so whilst a browser or OS may have a root certificate already, Java may not have shipped with it. 通常,这是由证书由未知的根证书颁发机构(CA)签名引起的,例如JRE尚不了解的公司自己的内部CA,甚至是由一些不太受欢迎的第三方根CA引起的。与其他一些知名厂商一样,因此尽管浏览器或OS可能已经具有根证书,但Java可能并未附带它。

To rectify this, you will also need to obtain and install the root CA certificate and mark it trusted too. 要解决此问题,您还需要获取并安装根CA证书,并将其也标记为受信任。

There are also companies that provide certificate signing that are acting as intermediaries, meaning that they don't have their own root CA themselves, but have been given a certificate by a trusted root CA to allow them to further sign certificate signing requests (CSRs). 也有提供证书签名的公司充当中介,这意味着它们本身没有自己的根CA,但是受信任的根CA授予了证书,以允许它们进一步签署证书签名请求(CSR) 。

In these cases, whilst you may have your own certificate and the underlying root CA already installed and trusted, unless you also obtain and install the intermediate certificate, then the 'certificate chain' is broken and a valid certificate path cannot be made. 在这些情况下,尽管您可能已经拥有自己的证书以及已经安装并受信任的基础根CA,但是除非您还获取并安装了中间证书,否则“证书链”将断开并且无法建立有效的证书路径。

So possible solutions in summary include: 因此,概括地说,可能的解决方案包括:

  1. Perform all certificate installations for other sites with the -trustcacerts parameter. 使用-trustcacerts参数为其他站点执行所有证书安装。
  2. Check that the root CA certificate exists in the keystore file also, if not, obtain and install it using keytool -importcert -trustcacerts as well. 还要检查密钥库文件中是否还存在根CA证书,如果不存在,请同时使用keytool -importcert -trustcacerts获取并安装它。
  3. Check if there is also an intermediate certificate to complete the full chain, and if so, obtain and install that using keytool -importcert -trustcacerts into the keystore file also. 检查是否还有中间证书来完成整个链,如果是,请使用keytool -importcert -trustcacerts获取并将其安装到密钥库文件中。

Note: Examining the .crt file in Windows by double-clicking the file can give you an opportunity to examine the certificate path and see if and which root and intermediary CAs were involved to help show what you will need. 注意:通过双击Windows中的.crt文件,可以为您提供检查证书路径的机会,并查看是否涉及了哪些根CA和中间CA来帮助您显示所需的内容。

Once a complete and valid certificate chain has been installed and trusted into the keystore file, the error should pass. 一旦安装了完整且有效的证书链并将其信任到密钥库文件中,该错误就会通过。

暂无
暂无

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

相关问题 javax.mail.MessagingException:无法将命令发送到SMTP主机 - javax.mail.MessagingException: Can't send command to SMTP host javax.mail.MessagingException:未知的SMTP主机 - javax.mail.MessagingException: Unknown SMTP host javax.mail.MessagingException:无法连接到SMTP主机? - javax.mail.MessagingException: Could not connect to SMTP host? Java错误javax.mail.MessagingException:无法连接到SMTP主机: - Java error javax.mail.MessagingException: Could not connect to SMTP host: javax.mail.MessagingException:无法连接到SMTP主机:smtp.gmail.com,端口:587无法管理解决此问题 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587 Can not manage to solve this problem javax.mail.MessagingException:无法连接到 SMTP 主机:smtp.gmail.com,端口:465; - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465; javax.mail.MessagingException:无法连接到 SMTP 主机:smtp.gmail.com,端口:587 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587 javax.mail.MessagingException: 530 5.7.57 SMTP; 在 MAIL FROM 期间,客户端未通过身份验证发送匿名邮件 - javax.mail.MessagingException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM 发送邮件错误,javax.mail.MessagingException:无法连接到SMTP主机:本地主机,端口:25; - Sending mail error, javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; javax.mail.MessagingException:无法连接到SMTP主机:<主机名>端口:25响应:554 - javax.mail.MessagingException: Could not connect to SMTP host : <host name> port : 25 response: 554
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM