(最終更新日時:2008-12-28 20:54:22)
OpenSSLによる自己認証局(自己認証サーバー)を作成し、その自己認証サーバーを認証局とした各サーバーのSSL証明書を作成します。
認証サーバー証明書の作成
認証サーバー証明書の作成準備を行います。
認証サーバーの証明書ディレクトリを
/home/ssl/CA にしています。
# mkdir /home/ssl
# cd /home/ssl
# cp /etc/pki/tls/openssl.cnf ca.cnf 定義ファイルをカスタマイズします
# vi ca.cnf
:
[ CA_default ]
dir = /home/ssl/CA # Where everything is kept
:
x509_extensions = v3_ca # The extentions to add to the cert
:
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = JP # 国名(2文字)
:
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Tokyo # 州名
localityName = Locality Name (eg, city)
localityName_default = Setagaya-ku # デフォルトの市名
0.organizationName = Organization Name (eg, company)
0.organizationName_default = System House ACT # 組織(会社)名
:
organizationalUnitName = Organizational Unit Name (eg, section)
#organizationalUnitName_default =
organizationalUnitName_default = Certification Authority # 組織名
:
[ v3_ca ]
:
# Some might want this also
# nsCertType = sslCA, emailCA
nsCertType = sslCA, emailCA # Netscape用にコメントを外します
:
# cd /etc/pki/tls/misc/
# cp CA CA.new スクリプトをカスタマイズします
# vi CA.new
:
SSLEAY_CONFIG="-config /home/ssl/ca.cnf" # 定義ファイルの場所を指定します
DAYS="-days 365" # 1 year
CADAYS="-days 3650" # 10 years # 有効期限を10年に変更しています
:
CATOP=/home/ssl/CA # 証明書用のディレクトリを定義します
:
認証サーバー証明書を作成します。
# cd /etc/pki/tls # 定義ファイルのディレクトリで作成します
# ps -ef > .rnd # 乱数ファイルを作成します
# ./misc/CA.new -newca
CA certificate filename (or enter to create)
[enter]
Making CA certificate ...
Generating a 1024 bit RSA private key
.................++++++
..............++++++
writing new private key to '/home/ssl/CA/private/./cakey.pem'
Enter PEM pass phrase:作成する認証サーバー証明書のパスフレーズ
Verifying - Enter PEM pass phrase:作成する認証サーバー証明書のパスフレーズ(再入力)
:
Country Name (2 letter code) [JP]:[enter]
State or Province Name (full name) [Tokyo]:[enter]
Locality Name (eg, city) [Setagaya-ku]:[enter]
Organization Name (eg, company) [System House ACT]:[enter]
Organizational Unit Name (eg, section) [Certification Authority]:[enter]
Common Name (eg, your name or your server's hostname) []:System House ACT CA
Email Address []:認証サーバー管理者のメールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:[enter]
An optional company name []:[enter]
Using configuration from /home/ssl/ca.cnf
Enter pass phrase for /home/ssl/CA/private/./cakey.pem:設定した認証サーバー証明書のパスフレーズ
Check that the request matches the signature
Signature ok
Certificate Details:
:
(認証サーバー証明書の情報)
:
X509v3 Basic Constraints:
CA:TRUE # TRUE であることを確認する
Netscape Cert Type: # Netscape用の設定を確認する
SSL CA, S/MIME CA
:
Write out database with 1 new entries
Data Base Updated
# chmod 700 /home/ssl/CA/private
# chmod 400 /home/ssl/CA/private/cakey.pem
クライアントPCへインストールするため、認証サーバー証明書をバイナリDERフォーマットに変換します。
# cd /home/ssl/CA
# openssl x509 -inform PEM -in cacert.pem -outform DER -out cacert.der
作成された
cacert.der をクライアントPCにインストールします。
クライアントPCで
cacert.der をダブルクリックします。
(※)証明書の内容を確認し、証明書のインストール(I)... へ進みます。
(※)証明書のインポートウィザードが開始されますので、次へ(N) > 進みます。
(※)証明書を保管するストアを指定し、次へ(N) > 進みます。
(※)ここでは、自動的に証明書ストアを選択させています。
(※)証明書のインポートウィザードを 完了 させ、インポートを行います。
(※)セキュリティ警告が出ますので、内容を確認し、はい(Y) で、インポートを続行します。
(※)インポートの完了メッセージが表示されます。
インターネットブラウザを起動して、ツールバーから
ツール(T) → インターネット オプション(I)... → コンテンツ → 証明書(C)...
でインストールされた証明書を確認します。
(※)信頼されたルート証明書機関内に存在することを確認します。
認証サーバー証明書の更新
認証サーバー証明書の有効期限が切れそうな場合、認証サーバー証明書を更新します。
# cd /home/ssl/CA
# (有効期限を確認します)
# openssl x509 -inform PEM -in cacert.pem -noout -text
:
Validity
Not Before: 有効期限(開始日時)
Not After : 有効期限(終了日時)
:
# (有効期限を更新します)
# openssl req -config /home/ssl/ca.cnf -new -x509 -days 3650 -key private/cakey.pem -out cacert.pem
Enter pass phrase for private/cakey.pem:更新対象の認証サーバー証明書のパスフレーズ
:
-----
# (以下は、更新対象の認証サーバーと同じ内容を入力します)
Country Name (2 letter code) [JP]:[enter]
State or Province Name (full name) [Tokyo]:[enter]
Locality Name (eg, city) [Setagaya-ku]:[enter]
Organization Name (eg, company) [System House ACT]:[enter]
Organizational Unit Name (eg, section) [Certification Authority]:[enter]
Common Name (eg, your name or your server's hostname) []:System House ACT CA
Email Address []:認証サーバー管理者のメールアドレス
# (クライアントPCへの再配付用にバイナリDERフォーマットに変換します)
# openssl x509 -inform PEM -in cacert.pem -outform DER -out cacert.der
クライアントPCから古い認証サーバー証明書を削除し、更新された
cacert.der をクライアントPCにインストールします。
サーバー証明書の作成
Web, Mail, FTP等の各サーバーでセキュア通信(SSL/TLS)を行うためのサーバー証明書を作成します。
サーバー証明書作成用に OpenSSL の定義ファイルをカスタマイズします。
# cd /home/ssl
# cp /etc/pki/tls/openssl.cnf server.cnf 定義ファイルをカスタマイズします
# vi server.cnf
:
[ CA_default ]
dir = /home/ssl/CA # Where everything is kept
:
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = JP # 国名(2文字)
:
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Tokyo # 州名
localityName = Locality Name (eg, city)
localityName_default = Setagaya-ku # デフォルトの市名
0.organizationName = Organization Name (eg, company)
0.organizationName_default = System House ACT # 組織(会社)名
:
organizationalUnitName = Organizational Unit Name (eg, section)
#organizationalUnitName_default =
organizationalUnitName_default = Certification Authority # 組織名
:
[ usr_cert ]
:
# This is OK for an SSL server.
# nsCertType = server
nsCertType = server # サーバー証明書を作成します
:
# cd /etc/pki/tls/misc/
# cp CA CA.server スクリプトをカスタマイズします
# vi CA.server
:
SSLEAY_CONFIG="-config /home/ssl/server.cnf" # 定義ファイルの場所を指定します
DAYS="-days 365" # 1 year
:
# (サーバー証明申請書、サーバー証明書、サーバー秘密鍵の保管場所を作成します)
# mkdir /home/ssl/server
# chmod 400 /home/ssl/server
サーバー秘密鍵と証明申請書(Certificate Signing Request:CSR)を生成します。
ここでは、
Webサーバー を例にします。
# mkdir /home/ssl/server/web サーバー証明書の生成・保管場所を作成します
# cd /home/ssl/server/web
# /etc/pki/tls/misc/CA.server -newreq
Generating a 1024 bit RSA private key
.....++++++
............................................................++++++
writing new private key to 'newkey.pem'
Enter PEM pass phrase:作成するサーバー証明書のパスフレーズ
Verifying - Enter PEM pass phrase:作成するサーバー証明書のパスフレーズ(再入力)
:
Country Name (2 letter code) [JP]:[enter]
State or Province Name (full name) [Tokyo]:[enter]
Locality Name (eg, city) [Setagaya-ku]:[enter]
Organization Name (eg, company) [System House ACT]:[enter]
Organizational Unit Name (eg, section) [Certification Authority]:[enter]
Common Name (eg, your name or your server's hostname) []:ssl.system-act.com サーバーのFQDN
Email Address []:サーバ管理者のメールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:[enter]
An optional company name []:[enter]
Request (and private key) is in newreq.pem
# chmod 400 newreq.pem
サーバー証明申請書にCAの署名を行いサーバー証明書を生成します。
# cd /home/ssl/server/web
# /etc/pki/tls/misc/CA.server -sign
Using configuration from /home/ssl/server.cnf
Enter pass phrase for /home/ssl/CA/private/cakey.pem:CAのパスフレーズ
Check that the request matches the signature
Signature ok
Certificate Details:
:
(証明申請書の内容)
:
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
:
(署名済証明書の内容)
:
Signed certificate is in newcert.pem
# mv newreq.pem server.req
# mv newcert.pem server.crt
# chmod 644 server.crt
パスフレーズ付きサーバー秘密鍵を作成します。
# cd /home/ssl/server/web
# openssl rsa -in newkey.pem -out server.key
Enter pass phrase for newreq.pem:サーバー証明書のパスフレーズ
writing RSA key
# chmod 400 server.key
# rm newkey.pem
# chmod 400 /home/ssl/server/web
クライアント証明書の作成
サーバアクセスの認証を行うため、クライアント証明書を作成します。
クライアント証明書作成用に OpenSSL の定義ファイルをカスタマイズします。
# cd /usr/share/ssl
# cp openssl.cnf client.cnf
# vi client.cnf
:
[ CA_default ]
dir = /usr/share/ssl/rootCA # Where everything is kept
:
default_days = 1825 # 有効期間(5年)
:
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = JP # 国名(2文字)
:
stateOrProvinceName_default = Tokyo # 州名
localityName = Locality Name (eg, city)
localityName_default = Setagaya-ku # デフォルトの市名
:
0.organizationName_default = System House ACT # 組織(会社)名
:
#organizationalUnitName_default =
organizationalUnitName_default = Certification Authority # 組織名
:
[ usr_cert ]
:
# For normal client use this is typical
# nsCertType = client, email
nsCertType = client, email # コメントを外します
:
# cp ./misc/CA ./misc/client.CA スクリプトをカスタマイズします
# vi ./misc/client.CA
:
SSLEAY_CONFIG="-config /usr/share/ssl/client.cnf" # 定義ファイルの場所を定義します
DAYS="-days 365"
:
CATOP=/usr/share/ssl/rootCA # 証明書用のディレクトリを定義します
:
-newreq)
:
$REQ -new -keyout newkey.pem -out newreq.pem $DAYS # 秘密鍵と証明申請書を別々に作成します
:
クライアント証明書の秘密鍵と証明申請書(Certificate Signing Request:CSR)を生成します。
# mkdir /usr/share/ssl/client デジタル署名用証明書の格納ディレクトリ
# cd /usr/share/ssl/client (任意のディレクトリ)
# /usr/share/ssl/misc/client.CA -newreq
Generating a 1024 bit RSA private key
.....................................++++++
.......................................++++++
writing new private key to 'newkey.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]:[enter]
State or Province Name (full name) [Tokyo]:[enter]
Locality Name (eg, city) [Setagaya-ku]:[enter]
Organization Name (eg, company) [System House ACT]:[enter]
Organizational Unit Name (eg, section) [Certification Authority]:[enter]
Common Name (eg, your name or your server's hostname) []:クライアント名
Email Address []:証明書管理者のメールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:[enter]
An optional company name []:[enter]
Request (and private key) is in newreq.pem
# mv newkey.pem クライアント名.key
# chmod 400 クライアント名.key
証明申請書にCAの署名を行い証明書を生成します。
# cd /usr/share/ssl/client
# /usr/share/ssl/misc/client.CA -sign
Using configuration from /usr/share/ssl/client.cnf
Enter pass phrase for /usr/share/ssl/rootCA/private/cakey.pem:CAのパスフレーズ
Check that the request matches the signature
Signature ok
Certificate Details:
:
(証明申請書の内容)
(CA証明書の情報)
:
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
:
(署名済証明書の内容)
:
Signed certificate is in newcert.pem
# mv -f newcert.pem クライアント名.crt
# chmod 644 クライアント名.crt
# # 失効処理用に証明申請書を保存しておきます
# mv -f newreq.pem クライアント名.req
証明書、秘密鍵、CA証明書のセットをPKCS#12形式で作成します。
# openssl pkcs12 -export -in クライアント名.crt -inkey クライアント名.key \
> -certfile /usr/share/ssl/rootCA/cacert.pem \
> -out クライアント名.p12
Enter pass phrase for objsign.key:証明書のパスフレーズ
Enter Export Password:証明書インストール時のパスフレーズ
Verifying - Enter Export Password:証明書インストール時のパスフレーズ(再入力)
作成された
クライアント名.p12 をクライアントにインストールします。
デジタル署名用証明書の作成
Microsoft OfficeのVBAコードに署名するため、デジタル署名用証明書を作成します。
デジタル署名用証明書作成用に OpenSSL の定義ファイルをカスタマイズします。
# cd /usr/share/ssl
# cp openssl.cnf objsign.cnf
# vi objsign.cnf
:
[ CA_default ]
dir = /usr/share/ssl/rootCA # Where everything is kept
:
default_days = 1825 # 有効期間(5年)
:
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = JP # 国名(2文字)
:
stateOrProvinceName_default = Tokyo # 州名
localityName = Locality Name (eg, city)
localityName_default = Setagaya-ku # デフォルトの市名
:
0.organizationName_default = System House ACT # 組織(会社)名
:
#organizationalUnitName_default =
organizationalUnitName_default = Certification Authority # 組織名
:
[ usr_cert ]
:
# For an object signing certificate this would be used.
# nsCertType = objsign
nsCertType = objsign # コメントを外します
:
# cp ./misc/CA ./misc/objsign.CA スクリプトをカスタマイズします
# vi ./misc/objsign.CA
:
SSLEAY_CONFIG="-config /usr/share/ssl/objsign.cnf" # 定義ファイルの場所を定義します
DAYS="-days 365"
:
CATOP=/usr/share/ssl/rootCA # 証明書用のディレクトリを定義します
:
-newreq)
:
$REQ -new -keyout newkey.pem -out newreq.pem $DAYS # 秘密鍵と証明申請書を別々に作成します
:
デジタル署名用証明書の秘密鍵と証明申請書(Certificate Signing Request:CSR)を生成します。
# mkdir /usr/share/ssl/objsign デジタル署名用証明書の格納ディレクトリ
# cd /usr/share/ssl/objsign (任意のディレクトリ)
# /usr/share/ssl/misc/objsign.CA -newreq
Generating a 1024 bit RSA private key
....++++++
.........++++++
writing new private key to 'newreq.key'
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]:[enter]
State or Province Name (full name) [Tokyo]:[enter]
Locality Name (eg, city) [Setagaya-ku]:[enter]
Organization Name (eg, company) [System House ACT]:[enter]
Organizational Unit Name (eg, section) [Certification Authority]:[enter]
Common Name (eg, your name or your server's hostname) []:System House ACT VBA Authority
Email Address []:証明書管理者のメールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:[enter]
An optional company name []:[enter]
Request (and private key) is in newreq.pem
# mv newkey.pem objsign.key
# chmod 400 objsign.key
証明申請書にCAの署名を行い証明書を生成します。
# cd /usr/share/ssl/objsign
# /usr/share/ssl/misc/objsign.CA -sign
Using configuration from /usr/share/ssl/objsign.cnf
Enter pass phrase for /usr/share/ssl/rootCA/private/cakey.pem:CAのパスフレーズ
Check that the request matches the signature
Signature ok
Certificate Details:
:
(証明申請書の内容)
(CA証明書の情報)
:
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
:
(署名済証明書の内容)
:
Signed certificate is in newcert.pem
# mv -f newcert.pem objsign.crt
# chmod 644 objsign.crt
証明書、秘密鍵、CA証明書のセットをPKCS#12形式で作成します。
# openssl pkcs12 -export -in objsign.crt -inkey objsign.key \
> -certfile /usr/share/ssl/rootCA/cacert.pem \
> -out vbacert.p12
Enter pass phrase for objsign.key:証明書のパスフレーズ
Enter Export Password:証明書インストール時のパスフレーズ
Verifying - Enter Export Password:証明書インストール時のパスフレーズ(再入力)
作成された
vbacert.p12 を利用者の環境にインストールします。
Copyright © 2004-2009 System House ACT. All Rights Reserved.