繁体   English   中英

在JBoss上安装SSL证书

[英]Installing SSL certificate on JBoss

我有一台运行JBoss的服务器。 当我输入错误的URL到该服务器时,它给我这样的版本:JBossWeb / 2.0.1.GA - 将是什么版本的JBoss? 我将购买并提供SSL证书,以便我可以将其安装在JBoss中。 我非常感谢任何HOWTO或任何有关如何在JBoss上安装现成SSL证书的信息。 当从其他销售SSL证书的公司购买此SSL证书时,是否需要使用openssl生成任何文件?

在此先感谢您的帮助。

您可以生成自己的SSL证书:

首先,您需要创建一个自签名证书。 您可以使用Java附带的keytools应用程序执行此操作。 打开命令提示符并运行以下命令。 您需要更改Jboss conf目录的路径以反映您的安装:

C:\>keytool -genkey -alias tomcat -keyalg RSA -keystore C:\jboss-2.0.1.GA\server\default\conf\localhost.keystore

提示时,到处使用changeit密码。 在第一个问题上回答localhost非常重要:

Enter keystore password: changeit
Re-enter new password: changeit
What is your first and last name?
  [Unknown]:  localhost
What is the name of your organizational unit?
  [Unknown]:
What is the name of your organization?
  [Unknown]:
What is the name of your City or Locality?
  [Unknown]:
What is the name of your State or Province?
  [Unknown]:
What is the two-letter country code for this unit?
  [Unknown]:  NZ
Is CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=NZ correct?
  [no]:  yes

Enter key password for
        (RETURN if same as keystore password): changeit
Re-enter new password: changeit
Next up you need to configure tomcat to create a SSL connector.

Edit C:\jboss-2.0.1.GA\server\default\deploy\jboss-web.deployer\server.xml and find the commented out SSL connector example, uncomment it and tweak it as follows:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="${jboss.server.home.dir}/conf/localhost.keystore"
keystorePass="changeit"
/>

最后,在Jboss启动命令中添加两个System属性,以使javax.net.ssl库使用新的密钥库。 只有在您需要将SSL呼叫回复给自己时才需要这些。 我需要它们,因为我有CAS和3个使用CAS进行身份验证的应用程序都运行在同一个开发Jboss实例中:

-Djavax.net.ssl.trustStore=C:\jboss-2.0.1.GA\server\default\conf\localhost.keystore
-Djavax.net.ssl.trustStorePassword=changeit

好的,现在浏览到http://localhost:8443/

您的浏览器会抱怨自签名证书。 只需按照浏览器的说明添加此证书作为安全例外,这样就不会再次提示您,并且您已完成所有操作。

我知道这篇文章很老了,我想分享更新版本的Wildfly(JBoss AS早期版本)所需的步骤。

首先,您需要创建自签名证书。 如果您已有密钥库,则可以跳过此步骤。

  • 转到Wildfly / Jboss主文件夹并创建一个名为“keystore”的新目录
  • 下载KeyStore Explorer应用程序。
  • 打开它并选择“创建一个新的KeyStore”
  • 在出现的对话框中,选择JKS。 在大多数情况下它很好,但在其他平台上,例如在Android上,您需要使用BKS格式类型。
  • 现在右键单击并选择“创建新密钥对”。 您可以安全地接受默认值。 (RSA / 2048)
  • 在显示的对话框中,根据您的需要对其进行自定义。 无论如何,我建议使用版本3和SHA-256与RSA。
  • 单击对话框右下方区域中的“编辑名称”按钮,该按钮对应于“名称”字段。 填写所有字段,然后单击“确定”。
  • 在另一个对话框中单击“确定”
  • 现在将要求插入别名的neme。 键入jbossWildfly并单击“确定”,然后插入将用于解锁此别名的密码。 我强烈建议您将这些数据保存在计算机的某个位置。
  • 现在您已成功生成密钥对。 使用我们之前创建的密钥库文件夹中的名称keystore.jks保存它,然后插入将用于解锁密钥库的新密码。 如果需要,您可以使用之前的相同内容。

现在打开位于以下位置的standalone.xml文件:

$ WILDFLY_HOME $ \\独立\\配置

并在<security-realms>标记内添加一个新的Security Realm:

<security-realm name="MyNewSecurityRealm">
       <server-identities>
            <ssl>
                <keystore path="$WILDFLY_HOME$\keystore\keystore.jks" keystore-password="keystore_password" alias="jbossWildfly" key-password="alias_password"/>
            </ssl>
       </server-identities>
</security-realm>

再次使用home dir的真实路径更改$ WILDFLY_HOME $并将密码更改为您键入的内容。

现在,您需要将新的安全领域分配给default-server的HTTPS侦听器:

<server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
            <https-listener name="https" socket-binding="https" security-realm="MyNewSecurityRealm" enable-http2="true"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <http-invoker security-realm="MyNewSecurityRealm"/>
            </host>
        </server>

请记住,默认情况下,HTTPS侦听器绑定到8443端口:

<socket-binding name="https" port="${jboss.https.port:8443}"/>

所以你对服务器的调用将是这样的:(在localhost上访问)

https://localhost:8443/

希望它可以帮助! :)

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM