home prev next

自己認証局と証明書の作成手順


クライアント証明書

クライアント証明は、限られた人のみアクセスを限定したいサイトを構築する場合に有効です。

クライアント署名要求書の作成

サーバの証明書と同様、自己認証局に署名してもらうクライアント署名要求書を作成します。
作業は /usr/local/openssl/CLIENT で行います。

Fig.3-1: クライアント秘密鍵作成作業の環境作成
# mkdir -p /usr/local/ssl/CLIENT
# chmod 700 /usr/local/ssl/CLIENT

場所準備が出来たら、クライアント用の秘密鍵を作成します。

Fig.3-2: クライアントの秘密鍵作成
# cd /usr/local/ssl/CLIENT
# /usr/local/ssl/bin/openssl genrsa -des3 -out client.key 1024
Generating RSA private key, 1024 bit long modulus
.........++++++
...........++++++
e is 65537 (0x10001)
Enter pass phrase for client.key: 【クライアント秘密鍵のパスフレーズを入力】
Verifying - Enter pass phrase for client.key: 【クライアント秘密鍵のパスフレーズの確認】

次に、クライアント署名要求書を作成します。

Fig.3-3: クライアント署名要求書の作成
# /usr/local/ssl/bin/openssl req -new -days 365 -key client.key -out clcsr.pem -config /usr/local/ssl/openssl.cnf
Enter pass phrase for client.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-ku
Organization Name (eg, company) [Internet Widgits Pty Ltd]:UMIYAMA SHOJI Co., Ltd.
Organizational Unit Name (eg, section) []:Eigyou
Common Name (eg, YOUR name) []:www.umiyama.co.jp
Email Address []:fuguta@umiyama.co.jp
 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: 【何も入力しない】
An optional company name []: 【何も入力しない】

ここで作成した署名要求書(clcsr.pem)をCA管理者に提出して署名してもらいます。
この作業はCA管理者が行う作業です(ここでは同一ホストで行っているのでその必要はありません)。


クライアント証明書の作成

以下のコマンドで署名してクライアント証明書を作成しますが、 OpenSSLの設定ファイルの「nsCertType」を "client, email" に変更する必要があるので注意が必要です。

Fig.3-4: クライアント証明書の作成
# /usr/local/ssl/bin/openssl ca -in clcsr.pem -out clcert.pem -config /usr/local/ssl/openssl.cnf
Using configuration from /usr/local/ssl/openssl.cnf
Enter pass phrase for /usr/.../private/cakey.pem: 【証明書のパスフレーズを入力】
Check that the request matches the signature
Signature ok
... (略) ...
Certificate is to be certified until Nov 17 07:56:00 2009 GMT (365 days)
Sign the certificate? [y/n]:y
 
 
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

クライアントでは PKCS12形式しか利用できないので clcert.pem を変換する。
変換には、CAの証明書(公開鍵)を含めた形で作業する。

Fig.3-5: クライアント証明書の作成
# openssl pkcs12 -export -in clcert.pem -inkey client.key -certfile ../CA/cacert.pem -out clcert.p12
Enter pass phrase for client.key: 【クライアント秘密鍵のパスフレーズを入力】
Enter Export Password: 【証明書を取り込む時のパスフレーズを設定】
Verifying - Enter Export Password: 【上記パスフレーズの確認】

Webサーバの設定

Apache の SSLディレクトリに、CAの証明書(cacert.pem)とクライアント証明の秘密鍵(client.key)、クライアント証明書(clcert.pem)を用意する。

Fig.3-6: クライアント証明を使うための httpd-ssl.conf の設定
SSLCertificateFile "/usr/local/ssl/SERVER/cert.pem"
SSLCertificateKeyFile "/usr/local/ssl/SERVER/servernopass.key"
SSLCertificateChainFile "/usr/local/ssl/CA/cacert.pem"
SSLCACertificatePath "/usr/local/ssl/CA"
SSLCACertificateFile "/usr/local/ssl/CA/cacert.pem"
SSLCARevocationPath "/usr/local/ssl/CLIENT"
SSLCARevocationFile "/usr/local/ssl/CLIENT/clcert.pem"
SSLVerifyClient require
SSLVerifyDepth 1

home prev next

Last-modified: Fri Nov 14 12:32:40 JSP 2008
Site admin:りお

Powerd by ninjatools

がんばりましょう このページは Another HTML-lint gatewayがんばりましょうと判断されました。