我有一个需要向greenmail服务器发送smtps消息的mule流。
mule flow使用带有configure keystore和truststore的smtps连接器:
<smtps:connector name="SMTPS_Connector" validateConnections="true" doc:name="SMTP">
<smtps:tls-client path="${keystore.path}" storePassword="${keystore.password}"/>
<smtps:tls-trust-store path="${truststore.path}" storePassword="${truststore.password}"/>
</smtps:connector>
我的绿色邮件服务器使用默认值启动。
当我调用我的流程发送电子邮件时,我得到以下日志:
在骡子日志中:
ERROR 2017-03-17 19:33:38,106 [Default_HTTP_Connector.receiver.06] org.mule.exception.DefaultMessagingExceptionStrategy: ************************************************** ******************************消息:无法连接到邮件传输。代码
:MULE_ERROR - 2 -------------------------------------------------- ------------------------------异常堆栈是: 1.找不到可信证书(sun.security.validator.ValidatorException)
sun.security.validator.SimpleValidator:396(null) 2. sun.security.validator.ValidatorException:找不到可信证书(javax.net.ssl.SSLHandshakeException)
sun.security.ssl.Alerts:192 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/net/ssl/SSLHandshakeException.html) 3.无法连接到SMTP主机:localhost,port:3465(javax.mail.MessagingException)com.sun.mail.smtp.SMTPTransport:1706 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/mail/MessagingException.html) 4.无法连接到邮件传输。 (org.mule.api.endpoint.EndpointException)
org.mule.transport.email.SmtpMessageDispatcher:67 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/endpoint/EndpointException.html) -------------------------------------------------- ------------------------------ Root异常堆栈跟踪:sun.security.validator.ValidatorException: 找不到可信证书 sun.security.validator.SimpleValidator.buildTrustedChain(SimpleValidator.java:396) 在 sun.security.validator.SimpleValidator.engineValidate(SimpleValidator.java:134) at sun.security.validator.Validator.validate(Validator.java:260) + 3个以上(设置调试级别日志记录或&#39; -Dmule.verbose.exceptions = true&#39;表示所有内容)
在Greenmail服务器日志中:
错误2017-03-17 19:33:38,086 [smtps:localhost:3465&lt; - / 127.0.0.1:27671] com.icegreen.greenmail.smtp.SmtpHandler:意外的错误处理 connection,quitting = javax.net.ssl.SSLException:已连接 shutdown:javax.net.ssl.SSLHandshakeException:收到致命警报: certificate_unknown at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1508)at at sun.security.ssl.AppInputStream.read(AppInputStream.java:92)at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)at java.io.InputStreamReader.read(InputStreamReader.java:184)at java.io.BufferedReader.fill(BufferedReader.java:154)at java.io.BufferedReader.readLine(BufferedReader.java:317)at java.io.BufferedReader.readLine(BufferedReader.java:382)at com.icegreen.greenmail.smtp.SmtpConnection.receiveLine(SmtpConnection.java:57) 在 com.icegreen.greenmail.smtp.SmtpHandler.handleCommand(SmtpHandler.java:82) 在com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:56) 在 com.icegreen.greenmail.server.AbstractServer $ 1.run(AbstractServer.java:163) 在java.lang.Thread.run(Thread.java:745)引起: javax.net.ssl.SSLHandshakeException:收到致命警报: certificate_unknown at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1991)at at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1098)at at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1344) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:721) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) 在sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)at at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)at java.io.PrintWriter.flush(PrintWriter.java:320)at com.icegreen.greenmail.util.InternetPrintWriter.println(InternetPrintWriter.java:91) 在 com.icegreen.greenmail.util.InternetPrintWriter.println(InternetPrintWriter.java:196) 在 com.icegreen.greenmail.smtp.SmtpConnection.send(SmtpConnection.java:48) 在 com.icegreen.greenmail.smtp.SmtpHandler.sendGreetings(SmtpHandler.java:76) 在com.icegreen.greenmail.smtp.SmtpHandler.run(SmtpHandler.java:53) ......还有2个
似乎我需要在Greenmail服务器上指定密钥库,但我找不到办法。
我尝试将greenmail.jks放入密码&#39; changeit&#39;在类路径中,它在启动时给我这个错误:
错误2017-03-17 17:42:24,185 [smtps:localhost:3465] com.icegreen.greenmail.util.DummySSLServerSocketFactory:不能 创建并初始化SSL java.security.UnrecoverableKeyException: 无法恢复密钥 sun.security.provider.KeyProtector.recover(KeyProtector.java:328)at at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:138) 在 sun.security.provider.JavaKeyStore $ JKS.engineGetKey(JavaKeyStore.java:55) 在java.security.KeyStore.getKey(KeyStore.java:804)at sun.security.ssl.SunX509KeyManagerImpl。(SunX509KeyManagerImpl.java:131) 在 sun.security.ssl.KeyManagerFactoryImpl $ SunX509.engineInit(KeyManagerFactoryImpl.java:68) 在javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:259) 在 com.icegreen.greenmail.util.DummySSLServerSocketFactory。(DummySSLServerSocketFactory.java:56) 在 com.icegreen.greenmail.util.DummySSLServerSocketFactory.getDefault(DummySSLServerSocketFactory.java:87) 在 com.icegreen.greenmail.server.AbstractServer.openServerSocket(AbstractServer.java:63) 在 com.icegreen.greenmail.server.AbstractServer.initServerSocket(AbstractServer.java:115) 在 com.icegreen.greenmail.server.AbstractServer.run(AbstractServer.java:86) 线程中的异常&#34; smtps:localhost:3465&#34; java.lang.IllegalStateException:无法创建和初始化SSL com.icegreen.greenmail.util.DummySSLServerSocketFactory。(DummySSLServerSocketFactory.java:65) 在 com.icegreen.greenmail.util.DummySSLServerSocketFactory.getDefault(DummySSLServerSocketFactory.java:87) 在 com.icegreen.greenmail.server.AbstractServer.openServerSocket(AbstractServer.java:63) 在 com.icegreen.greenmail.server.AbstractServer.initServerSocket(AbstractServer.java:115) 在 com.icegreen.greenmail.server.AbstractServer.run(AbstractServer.java:86) 引起:java.security.UnrecoverableKeyException:无法恢复密钥 at sun.security.provider.KeyProtector.recover(KeyProtector.java:328) 在 sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:138) 在 sun.security.provider.JavaKeyStore $ JKS.engineGetKey(JavaKeyStore.java:55) 在java.security.KeyStore.getKey(KeyStore.java:804)at sun.security.ssl.SunX509KeyManagerImpl。(SunX509KeyManagerImpl.java:131) 在 sun.security.ssl.KeyManagerFactoryImpl $ SunX509.engineInit(KeyManagerFactoryImpl.java:68) 在javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:259) 在 com.icegreen.greenmail.util.DummySSLServerSocketFactory。(DummySSLServerSocketFactory.java:56)
答案 0 :(得分:0)
你是如何创建greenmail.jks的?如果你正在使用&#34; keytool -genkey ....&#34;请注意,您将获得2个密码。
第一个引用.jks文件,第二个引用密钥密码。如果您使用此jks设置服务器,则必须同时设置&#34;密码&#34;和&#34;密码&#34;,否则您将收到错误:
sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:138)at sun.security.provider.JavaKeyStore $ JKS.engineGetKey(JavaKeyStore.java:55)at
keytool命令示例:
keytool -genkey -keyalg RSA -alias selfsigned -keystore greenmailServer.jks -storepass password -validity 360 -keysize 2048
按照步骤操作,注意您将被要求输入&#34;密码&#34;。
不幸的是,我无法帮助您设置smtp服务器,我想这不是替代它。
问候!
答案 1 :(得分:0)
要解决此问题,我必须将所有密码(密钥库,密钥)更改为greenmail的默认密码。目前,我无法更改正在使用的套接字工厂,因此我无法更改greenmail密码,因为它在套接字工厂中是硬编码的。