GlassFish SSLの設定(クライアント認証)
GlassFish のドメイン管理サーバ上でHTTP リスナーの設定をクライアント認証対応に変更
dashost > asadmin set “cluster1-config.http-service.http-listener.http-listener-2.ssl.client-auth-enabled = true” |
クライアント証明書の秘密鍵を作成
ca-admin > openssl genrsa -des3 -out /tmp/client-private-key 2048 Generating RSA private key, 2048 bit long modulus ……….+++ ………………………………….+++ e is 65537 (0x10001) Enter pass phrase for /tmp/client-private-key: Verifying – Enter pass phrase for /tmp/client-private-key: |
クライアント証明書用のCSRを作成
下記の例では便宜上,認証局(CA)上で CSR を生成していますが,CSRの生成はどの環境で構築しても問題ありません.
ca-admin > openssl req -new -days 365 -key /tmp/client-private-key -out /tmp/clientcsr.pem Enter pass phrase for /tmp/client-private-key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter ‘.’, the field will be left blank. —– Country Name (2 letter code) [AU]:JP State or Province Name (full name) [Some-State]:Tokyo Locality Name (eg, city) []:Setagaya Organization Name (eg, company) [Internet Widgits Pty Ltd]:Sun Microsystems Organizational Unit Name (eg, section) []:Software Practice Common Name (eg, YOUR name) []:Tarou Yamada Email Address []:Tarou.Yamada@Sun.COM Please enter the following ‘extra’ attributes |
認証局(CA)でクライアント証明書を署名
クライアント証明書のCSRを認証局(CA)で署名します。
ca-admin > openssl ca -config ./openssl-client.cnf -in /tmp/clientcsr.pem -out /tmp/signed-clientcert.pem Using configuration from ./openssl-client.cnf Enter pass phrase for ./demoCA/private/cakey.pem: Check that the request matches the signatureSignature ok Certificate Details: Serial Number: cd:ea:db:f4:c8:e3:93:92 Validity Not Before: Dec 4 08:27:14 2009 GMT Not After : Dec 4 08:27:14 2010 GMT (省略) |
署名されたクライアント証明書をGlassFishのキーストアにインポートするため,X.509形式に変更
ca-admin > openssl x509 -in /tmp/signed-clientcert.pem -out /tmp/signed-clientcert.x509 |
GlassFishのキーストアに対してクライアント証明書をインポート
dashost > keytool -import -alias yamada -file /tmp/signed-clientcert.x509 キーストアのパスワードを入力してください:[changeit] 新規パスワードを再入力してください:[changeit] 所有者: EMAILADDRESS=Tarou.Yamada@Sun.COM, CN=Tarou Yamada, OU=Software Practice, O=Sun Microsystems, ST=Tokyo, C=JP 発行者: EMAILADDRESS=caadmin@Sun.COM, CN=ca-server.sun.com, OU=Software Practice, O=Sun Microsystems, ST=Tokyo, C=JP シリアル番号: cdeadbf4c8e39392 有効期間の開始日: Fri Dec 04 17:27:14 JST 2009 終了日: Sat Dec 04 17:27:14 JST 2010 証明書のフィンガープリント: MD5: 59:06:3C:95:79:5D:31:D7:A3:92:0E:AA:A2:23:73:6D SHA1: 26:00:30:F1:15:DB:20:D4:8E:AF:99:AB:96:13:CB:17:DA:E5:71:15 署名アルゴリズム名: SHA1withRSA バージョン: 3 (省略) この証明書を信頼しますか? [no]: yes 証明書がキーストアに追加されました。 |
クライアント証明書をブラウザにインポートするためPKCS12形式に変換
ca-admin > openssl pkcs12 -export -in /tmp/signed-clientcert.pem -inkey /tmp/client-private-key -certfile ./demoCA/cacert.pem -out /tmp/clientcert.p12 Enter pass phrase for /tmp/client-private-key: Enter Export Password: Verifying – Enter Export Password: ca-admin > ls -l /tmp/clientcert.p12 -rw-r–r– 1 root root 3525 12月 4日 17:29 /tmp/clientcert.p12 |
最後にブラウザにPKCS12形式のクライアント証明書をインポートします.
上記で設定は完了です,ブラウザからアクセスしてみてください.
Entry filed under: Application Server/GlassFish. Tags: Administration, クライアント認証, GlassFish, SSL.