本文以 WildFly 10 为例(同样适用于 8,9),说明如何为 JBoss 开启 HTTPS。
系统环境说明:
OS: Ubuntu 16.04 LTS 64位
Wilfdly 版本: 10.1.0
其它说明:
示例中的 HTTPS 证书,来自 Let’s Encrypt。
申请方法,详见我的另一篇文章:“[原创] Let’s Encrypt 免费开启 HTTPS 之旅”。文章地址如下:http://yhz61010.iteye.com/blog/2365312
前提:
需要通过 Let’s Encrypt 申请到可用的证书文件及私钥(fullchain.pem 和 privkey.pem)。
需要生成 JKS 文件。生成方法详见我的另一篇文章:“[转] Create a Java Keystore (.JKS) from Let’s Encrypt Certificates”。文章地址如下:http://yhz61010.iteye.com/blog/2374317
开启 JBoss HTTPS
将生成的 JKS 文件拷贝到 JBoss 的配置目录中:1
cp keystore.jks /<jboss.home>/standalone/configuration/
编辑如下文件:
1
vim /<jboss.home>/standalone/configuration/standalone.xml
在
节点中,插入如下配置: 1
2
3
4
5
6
7<security-realm name="SslRealm">
<server-identities>
<ssl>
<keystore path="keystore.jks" relative-to="jboss.server.config.dir" keystore-password="<your password>" alias="<your alias name>" key-password="<your password>"/>
</ssl>
</server-identities>
</security-realm>之后,找到
节点,并修改其中的 节点的内容(先注释掉原有的 HTTPS 配置,再追加新的配置): 1
2<!--<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>-->
<https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>Tips:从 Wildfly 8 开始,Web subsystem 已经被 Undertow subsystem 替代了。
最后重新启动 JBoss 即可:1
2/<jboss.home>/bin/jboss-cli.sh --connect --controller=localhost:9990 command=:shutdown
/<jboss.home>/bin/standalone.sh &参考文献: