使用letencrypt证书在Wildfly 19上设置SSL证书

时间:2020-05-14 09:47:13

标签: java ssl https ssl-certificate wildfly

我正在尝试在CentOS上运行的wildfly 19.0.0-Final上实现SSL证书 具有Java openjdk版本“ 1.8.0_242”的centos-release-7-7.1908.0.el7.centos.x86_64 OpenJDK运行时环境(内部版本1.8.0_242-b08) OpenJDK 64位服务器VM(内部版本25.242-b08,混合模式)

我已执行以下步骤,将https://www.example.com域映射到我的wildfly内容工资单

我的密钥库位于以下位置: /opt/wildfly-19.0.0.Final/standalone/configuration/www.example.com.jks

将证书添加到服务器。 http://www.mastertheboss.com/jboss-server/jboss-security/complete-tutorial-for-configuring-ssl-https-on-wildfly

通过sh /opt/wildfly-19.0.0.Final/bin/jboss-cli.sh登录到管理控制台 连接

然后运行以下脚本

batch
# Configure Server Keystore
/subsystem=elytron/key-store=demoKeyStore:add(path=server.keystore,relative-to=jboss.server.config.dir, credential-reference={clear-text=secret},type=JKS)
# Server Keystore credentials  
/subsystem=elytron/key-manager=demoKeyManager:add(key-store=demoKeyStore,credential-reference={clear-text=secret})
# Server keystore Protocols  
/subsystem=elytron/server-ssl-context=demoSSLContext:add(key-manager=demoKeyManager,protocols=["TLSv1.2"]) 
# This is only needed if WildFly uses by default the Legacy security realm
/subsystem=undertow/server=default-server/https-listener=https:undefine-attribute(name=security-realm)
# Store SSL Context information in undertow
/subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=ssl-context,value=demoSSLContext)

run-batch

reload

现在它将在配置文件中添加一个tls部分

哪个看起来像

<tls>
    <key-stores>
        <key-store name="demoKeyStore">
        <credential-reference clear-text="secret"/>
        <implementation type="JKS"/>
        <file path="server.keystore" relative-to="jboss.server.config.dir"/>
        </key-store>
    </key-stores>
    <key-managers>
        <key-manager name="demoKeyManager" key-store="demoKeyStore">
        <credential-reference clear-text="secret"/>
        </key-manager>
    </key-managers>
    <server-ssl-contexts>
        <server-ssl-context name="demoSSLContext" protocols="TLSv1.2" key-manager="demoKeyManager"/>
    </server-ssl-contexts>
</tls>

停止Wildfly,开始对配置进行更改。 /usr/sbin/wildfly-19.0.0。最终停止 阻止野蝇:
将其更改为

 <tls>
                <key-stores>
                    <key-store name="demoKeyStore">
                        <credential-reference clear-text="Some1pwD"/>
                        <implementation type="JKS"/>
                        <file path="www.example.com.jks" relative-to="jboss.server.config.dir"/>
                    </key-store>
                </key-stores>
                <key-managers>
                    <key-manager name="demoKeyManager" key-store="demoKeyStore">
                        <credential-reference clear-text="Some1pwD"/>
                    </key-manager>
                </key-managers>
                <server-ssl-contexts>
                    <server-ssl-context name="demoSSLContext" protocols="TLSv1.2" key-manager="demoKeyManager"/>
                </server-ssl-contexts>
            </tls>

/usr/sbin/wildfly-19.0.0。最终开始

https://www.example.com工作时,我无法访问http://www.example.com上的野蝇

1 个答案:

答案 0 :(得分:0)

可以使用WildFly CLI从Let's Encrypt获得证书。看看下面的博客文章,其中介绍了如何执行此操作:

https://developer.jboss.org/people/fjuma/blog/2018/08/31/obtaining-certificates-from-lets-encrypt-using-the-wildfly-cli

在此处的第4.3.6节中还有其他文档:

https://docs.wildfly.org/19/WildFly_Elytron_Security.html#configure-ssltls

请注意,要使用新证书而不需要重新启动服务器,只需重新初始化密钥管理器(例如/subsystem=elytron/key-manager=httpsKM:init())。