WildFly 8至26.1.x的security-realm配置迁移求助
WildFly 8 到 26.1.x Security Realm 迁移指南
原配置分析
你的WildFly 8配置包含以下核心部分:
- 服务器SSL身份认证(基于keystore)
- 客户端证书信任库
- 本地用户认证
- Properties文件用户认证
迁移后的配置
WildFly 26.1.x对authentication下的truststore配置结构做了调整,需将其嵌套到<ssl>元素内。迁移后的完整配置如下:
<security-realm name="Realm"> <!-- 服务器身份认证:SSL证书配置,与旧版本一致 --> <server-identities> <ssl> <keystore path="/folder/keystore" relative-to="jboss.server.config.dir" keystore-password="****"/> </ssl> </server-identities> <!-- 认证配置:调整truststore的嵌套结构 --> <authentication> <!-- 客户端证书信任库:需嵌套在<ssl>元素下 --> <ssl> <truststore path="/folder/cacerts" relative-to="jboss.server.config.dir" keystore-password="****"/> </ssl> <!-- 本地用户认证:配置不变 --> <local default-user="$local" skip-group-loading="true"/> <!-- Properties文件用户认证:配置不变 --> <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/> </authentication> </security-realm>
关键注意事项
- 路径检查:
path="/folder/keystore"结合relative-to="jboss.server.config.dir"表示路径为${jboss.server.config.dir}/folder/keystore。如果你的实际路径是绝对路径,需移除relative-to属性,直接写绝对路径。 - 密码加密(推荐):生产环境不建议使用明文密码,可通过WildFly自带工具加密:
- 启动JBoss CLI:
./bin/jboss-cli.sh - 连接服务器:
connect - 创建凭证存储:
/subsystem=elytron/credential-store=myStore:add(location=credential-store.jceks, relative-to=jboss.server.config.dir, credential-reference={clear-text=store-password}) - 存储密码:
/subsystem=elytron/credential-store=myStore:add-alias(alias=keystore-password, secret-value={clear-text=your-keystore-password})
然后在配置中引用加密后的密码:keystore-password="${jboss.credential-store.myStore.keystore-password}"
- 启动JBoss CLI:
- 兼容性验证:WildFly 26.1.x仍支持legacy安全领域配置,但推荐迁移到Elytron子系统以获得更好的安全性和扩展性。
- 启动检查:配置完成后启动服务器,查看
standalone/log/server.log,确认无keystore/truststore加载失败的错误。
内容的提问来源于stack exchange,提问作者Ballon
相关产品推荐
相关产品推荐

