java 在 JBoss 7 中设置正确的信任库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14730421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting the right truststore in JBoss 7
提问by Steffen
I want to send EMails from a JBoss 7 application. The SMTP server needs a TLS connection with a self signed certificate. If I try to send a EMail I get a SSLHandshakeException because the server certificate cannot be checked. To fix this I have add this: http://springinpractice.com/2012/04/29/fixing-pkix-path-building-issues-when-using-javamail-and-smtp/(putting the SMTP server certificate into a java truststore file)
我想从 JBoss 7 应用程序发送电子邮件。SMTP 服务器需要带有自签名证书的 TLS 连接。如果我尝试发送电子邮件,我会收到 SSLHandshakeException,因为无法检查服务器证书。为了解决这个问题,我添加了这个:http: //springinpractice.com/2012/04/29/fixing-pkix-path-building-issues-when-using-javamail-and-smtp/(将 SMTP 服务器证书放入java信任库文件)
My problem is now how to set the truststore file to JBoss 7?
我现在的问题是如何将信任库文件设置为 JBoss 7?
I known at stackoverflow and on other forums there are several answer for that propblem. But I didn't found the right.
我知道在 stackoverflow 和其他论坛上有几个针对该问题的答案。但我没有找到合适的。
I have already tried followings:
我已经尝试了以下内容:
- adding
JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStore=/home/stewert.c-on/data/projects/keystore/devel.truststore -Djavax.net.ssl.trustStorePassword=123456"
to:- jboss-as-7.1.1.Final/bin/standalone.conf
- jboss-as-7.1.1.Final/bin/domain.conf
- jboss-as-7.1.1.Final/bin/appclient.conf
- adding
<jsse keystore-password="123456" keystore-url="/home/stewert.c-on/data/projects/keystore/devel.keystore" truststore-password="123456" truststore-url="/home/stewert.c-on/data/projects/keystore/devel.truststore"/>
to jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
- 添加
JAVA_OPTS="$JAVA_OPTS -Djavax.net.ssl.trustStore=/home/stewert.c-on/data/projects/keystore/devel.truststore -Djavax.net.ssl.trustStorePassword=123456"
到:- jboss-as-7.1.1.Final/bin/standalone.conf
- jboss-as-7.1.1.Final/bin/domain.conf
- jboss-as-7.1.1.Final/bin/appclient.conf
- 添加
<jsse keystore-password="123456" keystore-url="/home/stewert.c-on/data/projects/keystore/devel.keystore" truststore-password="123456" truststore-url="/home/stewert.c-on/data/projects/keystore/devel.truststore"/>
到 jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
But if I check at runtime the system environment variable with 'System.getProperty("javax.net.ssl.trustStore")' I get in every case null!
但是如果我在运行时检查系统环境变量 'System.getProperty("javax.net.ssl.trustStore")' 我在每种情况下都会得到 null!
My environment:
我的环境:
- Linux
- JBoss 7.1
- JDK 7
- I'm starting JBoss inside of eclipse Juno
- Linux
- JBoss 7.1
- JDK 7
- 我正在 eclipse Juno 中启动 JBoss
Anybody knows what's going wrong? Where must I set the truststore?
有谁知道出了什么问题?我必须在哪里设置信任库?
Thanks, Steffen
谢谢,史蒂芬
回答by Tom Anderson
Someone asked on the JBoss forum "javax.net.ssl.trustStore - only way to specify client trust?", and the answer is basically "yes".
在 JBoss 论坛上有人问“ javax.net.ssl.trustStore - 指定客户端信任的唯一方法?”,答案基本上是“是”。
Their approach was to set that in a system-properties
element in the server config XML, which seems like the best way to me too. Better than grubbing about in the run configuration files!
他们的方法是system-properties
在服务器配置 XML 的一个元素中设置它,这对我来说似乎也是最好的方法。比在运行配置文件中乱搞要好!