我注册了一个域并想为其设置 SSL 加密。我的域名提供商让我从 COMODO 获得 SSL 证书。我使用 openSSL 生成了一个 key 和一个 csr 文件:
openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr
该命令生成了私钥、myserver.key 和 csr 文件。我把csr的内容上传到comodo,他们验证通过后发给我以下文件:
Root CA Certificate - AddTrustExternalCARoot.crt
Intermediate CA Certificate - COMODORSAAddTrustCA.crt
Intermediate CA Certificate - COMODORSADomainValidationSecureServerCA.crt
Your PositiveSSL Certificate - mydomain.crt
我迷失了从这里去哪里。我遵循了这些说明:
并创建了一个 domain.keystore 文件,但我不确定这样做是否正确。我在 Jboss 中的配置现在如下所示:
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl name="mydomain" password="*****" protocol="TLSv1" certificate-key-file="../standalone/configuration/domain.keystore"/>
</connector>
但这似乎行不通。我在服务器日志中没有收到任何错误,页面只是超时了。如果我使用 http 它正常工作。有什么建议吗?
编辑:
我采用了不同的方法,我以这种方式生成了我的 keystore :
keytool -genkey -alias domain -keyalg RSA -keysize 2048 -keystore domain.keystore
然后我将新的 csr 信息上传到 comodo 并取回了三个 .crt 证书。我使用以下命令将它们导入到 keystore 中:
keytool -import -trustcacerts -alias domain -file domain.crt -keystore domain.keystore
然后我以这种方式在 standalone.xml 中使用 keystore :
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl name="domain-ssl" key-alias="domain" password="******" certificate-key-file="../standalone/configuration/domain.keystore" protocol="TLSv1"/>
</connector>
服务器启动了,但是当我尝试连接到它时,我的浏览器显示连接不受信任:
domain uses an invalid security certificate.
The certificate is not trusted because it is self-signed.
(Error code: sec_error_ca_cert_invalid)
最佳答案
我终于设法正确安装了!方法如下:
使用此命令将 COMODO 证书安装到您的 keystore 中:
keytool -import -trustcacerts -alias <filename> -file <filename>.crt -keystore domain.keystore
顺序如下:
» Root: AddTrustExternalCARoot.crt
» Intermediate 1: COMODOAddTrustServerCA.crt
» Intermediate 2: COMODOExtendedValidationSecureServerCA.crt
然后安装您的域证书:
keytool -import -trustcacerts -alias mykey -file yourDomainName.crt -keystore domain.keystore
您应该使用与生成 keystore 相同的别名而不是 mykey。如果你做的一切都正确,你应该得到这个输出:
Certificate reply was installed in keystore
任何其他意思,你可能没有使用正确的别名。您需要做的最后一件事是像这样修改您的 standalone.xml:
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl name="<domain>-ssl" key-alias="<domain>" password="******" certificate-key-file="../standalone/configuration/<domain>.keystore"/>
</connector>
你应该可以开始了!
关于java - Jboss7 上的 COMODO SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24578375/