1.2.9. 使用传统核心管理身份验证为单向 SSL/TLS 配置管理接口
仅使用单向 SSL/TLS 配置 JBoss EAP 管理接口进行通信可提高安全性。客户端和管理接口之间的所有网络流量都加密,这降低了安全攻击(如中间人攻击)的风险。
在这一过程中,禁用了与 JBoss EAP 实例的未加密通信。此过程适用于单机服务器和受管域配置。对于受管域,请为管理 CLI 命令加上前缀主机名称,例如: /host=master。
在执行在管理接口上启用单向 SSL/TLS 的步骤时,请不要重新加载配置,除非有明确指示。这样做可能会导致您被锁定在管理界面之外。
创建密钥存储来保护管理接口
此密钥存储必须采用 JKS 格式,因为管理接口与 JCEKS 格式的密钥存储不兼容。
使用以下内容生成密钥存储,将参数(如 alias、keypass 、 密钥存储、storage pass 和 dname) 的示例值替换为环境的正确值:
$ keytool -genkeypair -alias appserver -storetype jks -keyalg RSA -keysize 2048 -keypass password1 -keystore EAP_HOME/standalone/configuration/identity.jks -storepass password1 -dname "CN=appserver,OU=Sales,O=Systems Inc,L=Raleigh,ST=NC,C=US" -validity 730 -v
参数 有效期 指定密钥有效的天数。值 730 等于 2 年。
确保管理接口绑定到 HTTPS
运行单机服务器
为确保管理接口绑定到 HTTPS,您必须添加 management-https 配置并删除 management-http 配置。
使用以下 CLI 命令,将管理接口绑定到 HTTPS:
/core-service=management/management-interface=http-interface:write-attribute(name=secure-socket-binding, value=management-https)
/core-service=management/management-interface=http-interface:undefine-attribute(name=socket-binding)
运行受管域
通过添加 secure 属性中的 socket 元素。
-port 和移除端口配置,更改 management- interface
使用以下命令将管理接口绑定到 HTTPS:
/host=master/core-service=management/management-interface=http-interface:write-attribute(name=secure-port,value=9993)
/host=master/core-service=management/management-interface=http-interface:undefine-attribute(name=port)
可选:实施自定义 socket-binding-group
如果要使用自定义 socket-binding-group,您必须确保定义了 management-https 绑定,这默认绑定到端口 9993。您可以从服务器配置文件的 socket-binding-group 属性或使用管理 CLI 验证这一点:
/socket-binding-group=standard-sockets/socket-binding=management-https:read-resource(recursive=true)
{
"outcome" => "success",
"result" => {
"client-mappings" => undefined,
"fixed-port" => false,
"interface" => "management",
"multicast-address" => undefined,
"multicast-port" => undefined,
"name" => "management-https",
"port" => expression "${jboss.management.https.port:9993}"
}
}
创建新安全域
在本例中,使用 HTTPS 管理RealmHTTPS 的新安全域使用名为 https-mgmt-users.properties 的属性文件,位于 EAP_HOME/standalone/configuration/ 目录下,用于存储用户名和密码。
创建用于存储用户名和密码的属性文件。
用户名和密码可以在以后添加到 文件中,但对于现在,您需要创建名为
https-mgmt-users.properties的空文件,并将它保存到该位置。以下示例演示了使用touch命令,但您也可以使用文本编辑器等其他机制。示例:使用 touch 命令创建一个清空文件
$ touch EAP_HOME/standalone/configuration/https-mgmt-users.properties接下来,使用以下管理 CLI 命令创建一个名为
ManagementRealmHTTPS的新安全域:/core-service=management/security-realm=ManagementRealmHTTPS:add /core-service=management/security-realm=ManagementRealmHTTPS/authentication=properties:add(path=https-mgmt-users.properties,relative-to=jboss.server.config.dir)将用户添加到 属性文件。
此时,您已创建了一个新的安全域,并将其配置为使用属性文件进行身份验证。现在,您必须使用
add-user脚本将用户添加到该属性文件,此脚本位于EAP_HOME/bin/目录中。在运行add-user脚本时,您必须分别使用-up 和 -r选项来指定属性文件和安全域。从那里,add-user脚本将以交互方式提示您输入要存储在https-mgmt-users.properties文件中的用户名和密码信息。$ EAP_HOME/bin/add-user.sh -up EAP_HOME/standalone/configuration/https-mgmt-users.properties -r ManagementRealmHTTPS ... Enter the details of the new user to add. Using realm 'ManagementRealmHTTPS' as specified on the command line. ... Username : httpUser Password requirements are listed below. To modify these restrictions edit the add-user.properties configuration file. - The password must not be one of the following restricted values {root, admin, administrator} - The password must contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s) - The password must be different from the username ... Password : Re-enter Password : About to add user 'httpUser' for realm 'ManagementRealmHTTPS' ... Is this correct yes/no? yes .. Added user 'httpUser' to file 'EAP_HOME/configuration/https-mgmt-users.properties' ... Is this new user going to be used for one AS process to connect to another AS process? e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls. yes/no? no重要在配置使用属性文件存储用户名和密码的安全域时,建议每个域使用不与其他域共享的不同属性文件。
配置管理接口以使用新安全域
使用以下管理 CLI 命令,将管理接口配置为使用新的安全域:
/core-service=management/management-interface=http-interface:write-attribute(name=security-realm,value=ManagementRealmHTTPS)
配置管理接口以使用密钥存储
使用以下管理 CLI 命令,将管理接口配置为使用密钥存储:对于参数文件,密码和别名的值必须从 Create a Keystore 复制到保护管理接口步骤。
/core-service=management/security-realm=ManagementRealmHTTPS/server-identity=ssl:add(keystore-path=identity.jks,keystore-relative-to=jboss.server.config.dir,keystore-password=password1, alias=appserver)
要更新密钥存储密码,请使用以下 CLI 命令:
/core-service=management/security-realm=ManagementRealmHTTPS/server-identity=ssl:write-attribute(name=keystore-password,value=newpassword)
此时,您需要重新载入服务器配置:
reload
重新载入服务器配置后,日志应包含以下内容,只需在文本前面显示启动的服务数:
13:50:54,160 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0061: Http management interface listening on https://127.0.0.1:9993/management
13:50:54,162 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0052: Admin console listening on https://127.0.0.1:9993
管理接口现在侦听端口 9993,这可以确认该过程是否成功。
此时,CLI 将断开连接并且无法重新连接,因为端口绑定已更改。继续 下一步,更新 jboss-cli.xml 文件,以允许管理 CLI 重新连接。
更新 jboss-cli.xml 文件
如果使用管理 CLI 执行管理操作,则必须对 EAP_HOME/bin/jboss-cli.xml 文件进行以下更改:
-
将
<default-protocol>的值更新为https-remoting。 -
在
<default-controller>中,将<protocol>的值更新为https-remoting。 -
在
<default-controller>中,将<port>的值更新为9993。
示例: jboss-cli.xml
<jboss-cli xmlns="urn:jboss:cli:2.0">
<default-protocol use-legacy-override="true">https-remoting</default-protocol>
<!-- The default controller to connect to when 'connect' command is executed w/o arguments -->
<default-controller>
<protocol>https-remoting</protocol>
<host>localhost</host>
<port>9993</port>
</default-controller>
...
下次使用管理 CLI 连接到管理接口时,您必须接受服务器证书并根据 ManagementRealmHTTPS 安全域进行身份验证:
示例:接受服务器证书和验证
$ ./jboss-cli.sh -c
Unable to connect due to unrecognised server certificate
Subject - CN=appserver,OU=Sales,O=Systems Inc,L=Raleigh,ST=NC,C=US
Issuer - CN=appserver, OU=Sales, O=Systems Inc, L=Raleigh, ST=NC, C=US
Valid From - Tue Jun 28 13:38:48 CDT 2016
Valid To - Thu Jun 28 13:38:48 CDT 2018
MD5 : 76:f4:81:8b:7e:c3:be:6d:ee:63:c1:7a:b7:b8:f0:fb
SHA1 : ea:e3:f1:eb:53:90:69:d0:c9:69:4a:5a:a3:20:8f:76:c1:e6:66:b6
Accept certificate? [N]o, [T]emporarily, [P]ermenantly : p
Authenticating against security realm: ManagementRealmHTTPS
Username: httpUser
Password:
[standalone@localhost:9993 /]
如果您 同时 定义了 security-realm 和 ssl-context,JBoss EAP 将使用由 ssl-context 提供的 SSL/TLS 配置。