2.4. 使用 Elytron 在域模式中配置 SSL


在 JBoss EAP 7.1 或更高版本中,您可以使用 Elytron 在域模式中配置 SSL。

先决条件

  • JBoss EAP 7.1 或更高版本.
  • Elytron

流程

  1. 创建自签名证书以启用 SSL:

    keytool -genkey -alias jboss -keysize 2048 -validity 365 -keyalg RSA -sigalg SHA256withRSA -keystore jboss.jks -storepass jboss@123 -keypass jboss@123 -dname "CN=example.com, OU=JavaEE, O=Red Hat, C=IN"
    Copy to Clipboard Toggle word wrap
  2. 使用管理 CLI 创建密钥存储、key-manager 和 ssl-context。

    #Configure a keystore
    /profile=<profile-name>/subsystem=elytron/key-store=httpsKS:add(path="${jboss.home.dir}/ssl/jboss.jks", credential-reference={clear-text=jboss@123}, type=JKS)
    
    #Create a new key-manager
    /profile=<profile-name>/subsystem=elytron/key-manager=httpsKM:add(key-store=httpsKS,algorithm="SunX509",credential-reference={clear-text=jboss@123})
    
    #Configure new server-ssl-context reference with protocol and ciphers
    /profile=<profile-name>/subsystem=elytron/server-ssl-context=httpsSSC:add(key-manager=httpsKM,protocols=["TLSv1.2"])
    Copy to Clipboard Toggle word wrap
  3. 配置 undertow 子系统,以映射 Elytron ssl-context

    batch
    /profile=<profile-name>/subsystem=undertow/server=default-server/https-listener=https:undefine-attribute(name=security-realm)
    /profile=<profile-name>/subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=ssl-context,value=httpsSSC)
    run-batch
    Copy to Clipboard Toggle word wrap
  4. 可选: 保护 management-interface 以使用同一 ssl-context

    host-*.xml 文件定义域控制器和主机控制器的配置,该配置包含管理接口。要确保 SSL 配置成功,您必须在主机上再次定义 ssl-context

    #Configure a keystore on the master DC host
    /host=<host-name>/subsystem=elytron/key-store=httpsKS:add(path="${jboss.home.dir}/ssl/jboss.jks", credential-reference={clear-text=jboss@123}, type=JKS)
    
    #Create a new key-manager on the master DC host
    /host=<host-name>/subsystem=elytron/key-manager=httpsKM:add(key-store=httpsKS,algorithm="SunX509",credential-reference={clear-text=jboss@123})
    
    #Configure new server-ssl-context reference with protocol and ciphers on the master DC host
    /host=<host-name>/subsystem=elytron/server-ssl-context=httpsSSC:add(key-manager=httpsKM,protocols=["TLSv1.2"])
    
    #Configure the secure-port and ssl-context for management-http interface  on the master DC host
    /host=<host-name>/core-service=management/management-interface=http-interface:write-attribute(name=ssl-context,value=httpsSSC)
    
    /host=<host-name>/core-service=management/management-interface=http-interface:write-attribute(name=secure-port,value=9993)
    Copy to Clipboard Toggle word wrap
  5. 确保正确配置了信任存储,使远程主机控制器能够通过 SSL 连接到域控制器。如需更多信息,请参阅使用 Elytron 配置域和主机控制器之间的 SSL/TLS
  6. 重新载入服务器以确保更改有效:

    reload --host=<host-name>
    Copy to Clipboard Toggle word wrap

验证

  • 使用浏览器或在 Red Hat Enterprise Linux 命令行中打开SSL 来验证 TLS 连接:

    openssl s_client -connect host:8443
    Copy to Clipboard Toggle word wrap

    输出中显示有关证书和使用的 TLS 版本的信息。

    SSL-Session:
    Protocol: TLSv1.2
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat