自己CA局で「セキュリティ警告」の確認を無くす


さて、前項までの設定でも十分セキュリティで保護された通信をすることはできますが、このままでは保護されたページにアクセスするたびに「セキュリティの警告」を表示してしまいます。
そこで、CA認証局を設定し「CA公開鍵」が格納された「CA証明書」を発行してブラウザにインポートし保護されたページにアクセスするたびに必要だった「セキュリティの警告」確認を無くしてみることにしました。

本当は「信頼のおけるCA認証局」から取得すればいいんですが、そこまでのお金はかけられないので!!


Apacheが動いていたら止めて作業しましょうね!

# /usr/local/apache/bin/apachectl stop[Enter] もし自動起動で動いていたら # sh /usr/local/etc/rc.d/apache.sh stop[Enter] ですね。

1.SSL証明書の作成

スーパー・ユーザでカレント・ディレクトリを /usr/local/src/apache_1.3.31 にします。
# make certificate TYPE=custom[Enter]です。
la10# make certificate TYPE=custom
SSL Certificate Generation Utility (mkcert.sh)
Copyright (c) 1998-2000 Ralf S. Engelschall, All Rights Reserved.

Generating custom certificate signed by own CA [CUSTOM]
______________________________________________________________________

STEP 0: Decide the signature algorithm used for certificates
The generated X.509 certificates can contain either
RSA or DSA based ingredients. Select the one you want to use.
Signature Algorithm ((R)SA or (D)SA) [R]:R
______________________________________________________________________

STEP 1: Generating RSA private key for CA (1024 bit) [ca.key]
3610841 semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
...++++++
...............++++++
e is 65537 (0x10001)
______________________________________________________________________

STEP 2: Generating X.509 certificate signing request for CA [ca.csr]
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.
-----
1. Country Name (2 letter code) [XY]:JP
2. State or Province Name (full name) [Snake Desert]:Miyagi
3. Locality Name (eg, city) [Snake Town]:Sendai
4. Organization Name (eg, company) [Snake Oil, Ltd]:Communication Socie
ty
5. Organizational Unit Name (eg, section) [Certificate Authority]:
6. Common Name (eg, CA name) [Snake Oil CA]:takaq CA
7. Email Address (eg, name@FQDN) [ca@snakeoil.dom]:master@takaq1.plal
a.jp
8. Certificate Validity (days) [365]:365

______________________________________________________________________

STEP 3: Generating X.509 certificate for CA signed by itself [ca.crt]
Certificate Version (1 or 3) [3]:3
Signature ok
subject=/C=JP/ST=Miyagi/L=Sendai/O=Communication Society/OU=Certificate Authorit
y/CN=takaq CA/emailAddress=master@takaq1.plala.jp
Getting Private key
Verify: matching certificate & key modulus
Verify: matching certificate signature
../conf/ssl.crt/ca.crt: /C=JP/ST=Miyagi/L=Sendai/O=Communication Society/OU=Cert
ificate Authority/CN=takaq CA/emailAddress=master@takaq1.plala.jp
error 18 at 0 depth lookup:self signed certificate
OK
______________________________________________________________________

STEP 4: Generating RSA private key for SERVER (1024 bit) [server.key]
3610841 semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
..............++++++
...........++++++
e is 65537 (0x10001)
______________________________________________________________________

STEP 5: Generating X.509 certificate signing request for SERVER [server.csr]
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.
-----
1. Country Name (2 letter code) [XY]:JP
2. State or Province Name (full name) [Snake Desert]:Miyagi
3. Locality Name (eg, city) [Snake Town]:Sendai
4. Organization Name (eg, company) [Snake Oil, Ltd]:Communication Socie
ty
5. Organizational Unit Name (eg, section) [Webserver Team]:
6. Common Name (eg, FQDN) [www.snakeoil.dom]:takaq1.plala.jp
7. Email Address (eg, name@fqdn) [www@snakeoil.dom]:master@takaq1.pla
la.jp
8. Certificate Validity (days) [365]:365

______________________________________________________________________

STEP 6: Generating X.509 certificate signed by own CA [server.crt]
Certificate Version (1 or 3) [3]:3
Signature ok
subject=/C=JP/ST=Miyagi/L=Sendai/O=Communication Society/OU=Webserver Team/CN=ta
kaq1.plala.jp/emailAddress=master@takaq1.plala.jp
Getting CA Private Key
Verify: matching certificate & key modulus
Verify: matching certificate signature
../conf/ssl.crt/server.crt: OK
______________________________________________________________________

STEP 7: Enrypting RSA private key of CA with a pass phrase for security [ca.key]
The contents of the ca.key file (the generated private key) has to be
kept secret. So we strongly recommend you to encrypt the server.key file
with a Triple-DES cipher and a Pass Phrase.
Encrypt the private key now? [Y/n]: Y
writing RSA key
Enter PEM pass phrase:パスフレーズの入力
Verifying - Enter PEM pass phrase:パスフレーズの確認入力

Fine, you're using an encrypted private key.
______________________________________________________________________

STEP 8: Enrypting RSA private key of SERVER with a pass phrase for security [ser
ver.key]
The contents of the server.key file (the generated private key) has to be
kept secret. So we strongly recommend you to encrypt the server.key file
with a Triple-DES cipher and a Pass Phrase.
Encrypt the private key now? [Y/n]: Y
writing RSA key
Enter PEM pass phrase:パスフレーズの入力
Verifying - Enter PEM pass phrase:パスフレーズの確認入力

Fine, you're using an encrypted RSA private key.
______________________________________________________________________

RESULT: CA and Server Certification Files

o conf/ssl.key/ca.key
The PEM-encoded RSA private key file of the CA which you can
use to sign other servers or clients. KEEP THIS FILE PRIVATE!

o conf/ssl.crt/ca.crt
The PEM-encoded X.509 certificate file of the CA which you use to
sign other servers or clients. When you sign clients with it (for
SSL client authentication) you can configure this file with the
'SSLCACertificateFile' directive.

o conf/ssl.key/server.key
The PEM-encoded RSA private key file of the server which you configure
with the 'SSLCertificateKeyFile' directive (automatically done
when you install via APACI). KEEP THIS FILE PRIVATE!

o conf/ssl.crt/server.crt
The PEM-encoded X.509 certificate file of the server which you configure
with the 'SSLCertificateFile' directive (automatically done
when you install via APACI).

o conf/ssl.csr/server.csr
The PEM-encoded X.509 certificate signing request of the server file which
you can send to an official Certificate Authority (CA) in order
to request a real server certificate (signed by this CA instead
of our own CA) which later can replace the conf/ssl.crt/server.crt
file.

Congratulations that you establish your server with real certificates.

la10#
STEP2 がCA認証局の STEP5 がサーバーに関する情報です。
これにより /usr/local/src/apche1_3.31/conf の下に ssl.crl, ssl.crt, ssl.csr, ssl.key, ssl.prm というディレクトリが出来ていました。ここで必要なのは次のファイルです。
ssl.crt/server.crt  ← サーバの公開鍵(CAによる署名済み)
        ca.crt     ← CAの公開鍵

ssl.key/server.key    ← サーバの秘密鍵
        ca.key     ← CAの秘密鍵

ssl.csr/server.csr  ← サーバの公開鍵(CAに署名してもらう際に提出する・・・のだそうです!)
カレントディレクトリを /usr/local/src/apche1_3.31/conf に移動します。
# cp -R ssl* /usr/local/apache/conf[Enter] としてコピーしました。
そして、/usr/local/apache/conf の下にある ssl.crl, ssl.crt, ssl.csr, ssl.key, ssl.prm 内をchmodroot権限の読み取りのみ許可(400)しました。(セキュリティのため)

2.公開鍵をサイトで公開

カレントディレクトリを /usr/local/apache/conf/ssl.crt にして以下のコマンドを実行しました。
# openssl x509 -inform pem -outform der < ca.crt > ca.der
・・・・でDER形式のCA公開鍵を作成しました。
そして /usr/local/apche/conf/mime.typesvi で開き次の1行を加えました。
application/x-x509-ca-cert   der
作成した公開鍵 ca.der をWebサイトの適当な場所に保管しコンテンツにリンクしておきます。
そして、Apacheを再起動しました。
# /usr/local/apache/bin/apachectl startssl[Enter] もし自動起動で動いていたら # sh /usr/local/etc/rc.d/apache.sh start[Enter] ですね。(起動時はサーバーのパスフレーズを入力します。)

3.ブラウザでのCA認証局証明書の受け入れ

ブラウザから証明書のあるURLにアクセスします。(例 : http://takaq1.plala.jp:8081/ca/ca.der)
・次のようなのを表示しますので、「開く」を選択します。
・「開く」と下のようなの表示しますので「証明書のインストール」をクリックします。
・下のようなウィザードになりますので「次へ」をクリック
・次のはそのまま「次へ」をクリックします。
・ここは迷わず「完了」です。すると・・・・
・これも迷わず「はい」です。
・下のになったらインストールOKです。
・ブラウザの「ツール」→「インターネットオプション」→「コンテンツ」→「証明書」→「信頼されたルート証明機関」にあればOKです。

「セキュリティで保護されたページ」にスムーズに行けます。


PC-9821La10活用苦労談へ戻る

FreeBSD活用苦労談へ戻る

サイトトップへ