認証局(CA)の構築
認証局構築にはopensslを利用します。opensslは、FreeのSSL構築環境を一通り提供しています。環境設定ファイルの所在等はFreeBSDをベースにしていますが、各自の環境に応じて読み換えてください。サーバ証明用に認証局を構築することを前提として、以下の設定をopenssl.cnfファイルに導入します。FreeBSDシステムでは、/usr/local/openssl/以下に存在します。36
37 dir = /usr/local/openssl/i-sys # Where everything is kept
123 [ req_distinguished_name ]
124 countryName = Country Name (2 letter code)
125 countryName_default = JP
126 countryName_min = 2
127 countryName_max = 2
128
129 stateOrProvinceName = State or Province Name (full name)
130 stateOrProvinceName_default = Ishikawa Pref.
131
132 localityName = Locality Name (eg, city)
133 localityName_default = Nanao City
134
135 0.organizationName = Organization Name (eg, company)
136 0.organizationName_default = Integrated Systems Co. Ltd.
137
138 # we can do this but it is not needed normally :-)
139 #1.organizationName = Second Organization Name (eg, company)
140 #1.organizationName_default = World Wide Web Pty Ltd
141
142 organizationalUnitName = Organizational Unit Name (eg, section)
143 organizationalUnitName_default = Network
169 # Here are some examples of the usage of nsCertType. If it is omitted
170 # the certificate can be used for anything *except* object signing.
171
172 # This is OK for an SSL server.
173 nsCertType = server
認証局の作成にはopenssl付属のCA.shを利用します。FreeBSDでports環境を利用してopensslを導入した場合には、
以下手順では、
# cd /usr/local/openssl/i-sys
# cp /usr/local/openssl/bin/CA.sh ./
CAKEY=./cakey.pem
CAREQ=./careq.pem
CACERT=./cacert.pem
CATOP | 認証局構築ディレクトリ |
CAKEY | 秘密鍵ファイル名 |
CAREQ | 証明書署名要求ファイル名 |
CACERT | 証明書ファイル名 |
以上で準備は完了です。CA.shスクリプトを利用して認証局の情報を登録します。
ksakurai@nsa# ./CA.sh -newca
mkdir: /usr/local/openssl/i-sys: File exists
CA certificate filename (or enter to create) ← [Enter]を入力
Making CA certificate ...
Generating a 1024 bit RSA private key
....................................++++++
.............................++++++
writing new private key to '/usr/local/openssl/rso-sys/private/./cakey.pem'
Enter PEM pass phrase: ←証明機関パスワードを入力
Verifying - Enter PEM pass phrase: ←上記パスワードを再入力
-----
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) [JP]: ←国名を入力(日本は通常JP)
State or Province Name (full name) [Ishikawa]: ←都道府県名を入力
Locality Name (eg, city) [Nanao]: ←市区町村名を入力
Organization Name (eg, company) [Integrated Systems Inc.]: ←組織名を入力
Organizational Unit Name (eg, section) [Network]: ←部署名を入力
Common Name (eg, YOUR name) []:www.i-sys.biz ←サーバ名を入力
Email Address []:ksakurai@i-sys.biz ←連絡先E-Mailアドレスを入力
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: ←特に入力なし
An optional company name []: ←特に入力なし
Using configuration from /usr/local/openssl/openssl.cnf
Enter pass phrase for /usr/local/openssl/rso-sys/private/./cakey.pem:
Check that the request matches the signature
Signature ok
正常に完了すると、指定ディレクトリいかに一連のファイルが作成されます。
total 24
drwxr-xr-x 6 root wheel 512 Nov 7 02:34 ./
drwxr-xr-x 9 root wheel 512 Nov 7 02:33 ../
-rwxr-xr-x 1 root wheel 3776 Nov 7 02:33 CA.sh*
-rw-r--r-- 1 root wheel 3319 Nov 7 02:34 cacert.pem
-rw-r--r-- 1 root wheel 729 Nov 7 02:34 careq.pem
drwxr-xr-x 2 root wheel 512 Nov 7 02:33 certs/
drwxr-xr-x 2 root wheel 512 Nov 7 02:33 crl/
-rw-r--r-- 1 root wheel 0 Nov 7 02:33 index.txt
drwxr-xr-x 2 root wheel 512 Nov 7 02:33 newcerts/
drwxr-xr-x 2 root wheel 512 Nov 7 02:33 private/
-rw-r--r-- 1 root wheel 3 Nov 7 02:33 serial
作成された証明書は、opensslコマンドを利用して内容確認できます。
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 0 (0x0)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=JP, ST=Ishikawa, O=Integrated Systems Inc., OU=Network, CN=i-sys/emailAddress=info@i-sys.biz
Validity
Not Before: Sep 30 06:43:06 2008 GMT
Not After : Sep 30 06:43:06 2011 GMT
Subject: C=JP, ST=Ishikawa, O=Integrated Systems Inc., OU=Network, CN=i-sys/emailAddress=info@i-sys.biz
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (1024 bit)
・・・
作成されたPEMフォーマットの証明書をバイナリDERフォーマットに変換する場合には以下コマンドを利用します。