A.6. Elytron Client Side Twoay の例
サーバー SSL コンテキストの設定後、可能な場合は設定をテストすることが重要です。Elytron クライアント SSL コンテキストは設定ファイルに配置して、その後に管理 CLI から実行できます。これにより、サーバー設定の機能的なテストが可能になります。以下の手順は、サーバー側の設定が完了し、必要に応じてサーバーがリロードされていることを前提としています。
サーバーおよびクライアントのキーストアがすでに存在する場合は次のステップに移行し、存在しない場合はサーバーとクライアントのキーストアを作成します。
$ keytool -genkeypair -alias localhost -keyalg RSA -keysize 1024 -validity 365 -keystore server.keystore.jks -dname "CN=localhost" -keypass secret -storepass secret $ keytool -genkeypair -alias client -keyalg RSA -keysize 1024 -validity 365 -keystore client.keystore.jks -dname "CN=client" -keypass secret -storepass secret
サーバー証明書およびクライアント証明書がすでにエクスポートされている場合は、次のステップに進んでください。エクスポートされていない場合は、サーバー証明書およびクライアント証明書をエクスポートします。
$ keytool -exportcert -keystore server.keystore.jks -alias localhost -keypass secret -storepass secret -file server.cer $ keytool -exportcert -keystore client.keystore.jks -alias client -keypass secret -storepass secret -file client.cer
サーバーの証明書をクライアントのトラストストアにインポートします。
$ keytool -importcert -keystore client.truststore.jks -storepass secret -alias localhost -trustcacerts -file server.cer
クライアント証明書をサーバーのトラストストアにインポートします。
$ keytool -importcert -keystore server.truststore.jks -storepass secret -alias client -trustcacerts -file client.cer
example-security.xml
内でクライアント側の SSL コンテキストを定義します。この設定ファイルには、アウトバウンド接続の認証および SSL 設定を定義する Elytronauthentication-client
が含まれます。以下のファイルは、クライアント SSL コンテキストとキーストアの定義を示しています。<?xml version="1.0" encoding="UTF-8"?> <configuration> <authentication-client xmlns="urn:elytron:client:1.2"> <key-stores> <key-store name="clientStore" type="jks" > <file name="/path/to/client.truststore.jks"/> <key-store-clear-password password="secret" /> </key-store> </key-stores> <key-store name="clientKeyStore" type="jks" > <file name="/path/to/client.keystore.jks"/> <key-store-clear-password password="secret" /> </key-store> <ssl-contexts> <ssl-context name="client-SSL-context"> <trust-store key-store-name="clientStore" /> <key-store-ssl-certificate key-store-name="clientKeyStore" alias="client"> <key-store-clear-password password="secret" /> </key-store-ssl-certificate> </ssl-context> </ssl-contexts> <ssl-context-rules> <rule use-ssl-context="client-SSL-context" /> </ssl-context-rules> </authentication-client> </configuration>
管理 CLI を使用して、新しく作成されたファイルを参照し、サーバーへのアクセスを試行します。以下のコマンドは管理インターフェイスにアクセスし、
whoami
コマンドを実行します。$ EAP_HOME/bin/jboss-cli.sh -c --controller=remote+https://127.0.0.1:9993 -Dwildfly.config.url=/path/to/example-security.xml :whoami
改訂日時: 2024-02-09