2.2. 为客户端证书配置信任存储和信任管理器
使用客户端证书和信任管理器配置信任存储,并引用信任存储,以便在 TLS 握手期间验证客户端证书。
先决条件
您已获取或生成了客户端证书。
如需更多信息,请参阅生成客户端证书。
- JBoss EAP 正在运行。
流程
使用管理 CLI 使用客户端证书配置信任存储。
创建服务器信任存储,以存储要信任的客户端证书。
语法
/subsystem=elytron/key-store=<server_trust_store_name>:add(path=<path_to_server_trust_store_file>,credential-reference={<password>})
Example
/subsystem=elytron/key-store=exampleServerTrustStore:add(path=exampleTLSServer.truststore,relative-to=jboss.server.config.dir,credential-reference={clear-text=secret}) {"outcome" => "success"}
通过指定客户端证书别名,将客户端证书导入到服务器信任存储中。只有提供服务器信任存储信任的证书的客户端才能连接到服务器。
注意如果您使用自签名证书配置双向 SSL/TLS,请将
validate
设置为false
,因为证书没有信任链。如果您要使用 CA 签名的证书在生产环境中配置双向 SSL/TLS,请将
validate
设置为true
。语法
/subsystem=elytron/key-store=<server_trust_store_name>:import-certificate(alias=<alias>,path=<certificate_file>,credential-reference={<password>},trust-cacerts=<true_or_false>,validate=<true_false>)
Example
/subsystem=elytron/key-store=exampleServerTrustStore:import-certificate(alias=client,path=client.cer,relative-to=jboss.server.config.dir,credential-reference={clear-text=serverTrustSecret},trust-cacerts=true,validate=false) {"outcome" => "success"}
将客户端证书导出到信任存储文件中。
语法
/subsystem=elytron/key-store=<server_trust_store_name>:store()
Example
/subsystem=elytron/key-store=exampleServerTrustStore:store() { "outcome" => "success", "result" => undefined }
配置信任管理器,以在 TLS 握手过程中验证客户端证书。
语法
/subsystem=elytron/trust-manager=<trust_manager_name>:add(key-store=<server_trust_store_name>)
Example
/subsystem=elytron/trust-manager=exampleTLSTrustManager:add(key-store=exampleServerTrustStore) {"outcome" => "success"}
配置的信任存储中的客户端证书用于验证客户端在与服务器的 TLS 握手期间显示的证书。