考え方†
- mvc (=kgb.hmuna.com) には公式なサーバー証明書を導入済み
- mvc のログイン認証は local IP ゾーン(VPN 接続を含む)は認証なし、その他は One Time パスワード認証を要求
- これに加えクライアント認証を導入し、認証済クライアントはパスワード無しで接続できるようにしたい
- 発行済のサーバー証明書からクライアント証明書を発行する方法が無い(CoMoDo には別にクライアント認証オプションあり)
- 一方でオレオレ認証ベースでのクライアント証明書を発行する事例は多数参考記事がある
- (方針)クライアント証明書については、公式サーバー証明書とは別にオレオレ認証局で作り Apache2 に組み込んで動作確認する
- この考え方(=サーバー証明書とクライアント証明書は別の認証局を使う)で正しいことを CyberTrust に確認した。
オリジナルの Apache2 の設定†
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
# Server Certificate:
SSLCertificateFile /etc/ssl/official5/kgb_hmuna_com.crt <---- これは KoMoDo から発行された証明書
# Server Private Key:
SSLCertificateKeyFile /etc/ssl/official5/kgb.hmuna.com.privatekey <---- これも KoMoDo から発行されたもの
# Server Certificate Chain:
# Apache 2.4.8 以降 SSLCertificateChainFile は無くなった? (らしいので無効にしてみる)
#SSLCertificateChainFile /etc/ssl/official4/kgb_hmuna_com.ca-bundle <---- これは使っていない
# 実験中(クライアント証明書)
# Client Certificate: (official CA (COMODO) to generate client certificate)
#SSLCACertificateFile /etc/ssl/private_CA/kgb_hmuna-client1.crt <---- このファイルはサーバー証明書に紐付いている、さて....
#SSLVerifyClient optional
再挑戦 2020-09 (/etc/ssl/private2_for_clientcertificate で作業)†
プライベート認証局を作成†
- ダミー認証局用の openssl 設定ファイルを用意(openssl-ca.cnf とリネーム)
openssl-ca.cnf
munakata@mvc:/etc/ssl/private2_for_client_certificate$ diff openssl-ca.cnf ../openssl.cnf
73c73
< default_days = 3650 # how long to certify for
---
> default_days = 365 # how long to certify for
170c170
< basicConstraints=CA:TRUE
---
> basicConstraints=CA:FALSE
183d182
< nsCertType = sslCA, emailCA
217d215
< keyUsage = cRLSign, keyCertSign
- パスフレーズ = magumaguking (サーバー証明書発行とは別にする)
munakata@mvc:/etc/ssl/private2_for_client_certificate$ sudo openssl genrsa -des3 -out ca.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
.............................+++++
...................................................+++++
e is 65537 (0x010001)
Enter pass phrase for ca.key:
Verifying - Enter pass phrase for ca.key:
munakata@mvc:/etc/ssl/private2_for_client_certificate$ sudo chmod 400 ca.key
munakata@mvc:/etc/ssl/private2_for_client_certificate$ ls -la
合計 24
drwxr-xr-x 2 root root 4096 9月 4 17:38 .
drwxr-xr-x 12 root root 4096 9月 4 15:57 ..
-r-------- 1 root root 1751 9月 4 17:38 ca.key
-rw-r--r-- 1 root root 10895 9月 4 16:16 openssl-ca.cnf
- プライベート認証局の証明書 (ca.crt)
- CN = nanamocha.com ----- あえて架空(無効)の名前を設定
munakata@mvc:/etc/ssl/private2_for_client_certificate$ sudo openssl req -new -x509 -days 3650 -sha256 -key ./ca.key -out ./ca.crt -config ./openssl-ca.cnf
Enter pass phrase for ./ca.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]:Kanagawa
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Magu
Organizational Unit Name (eg, section) []:Mocha
Common Name (e.g. server FQDN or YOUR name) []:nanamocha.com
Email Address []:
クライアント証明書の作成†
- クライアント証明書用の openssl 設定ファイルを用意(openssl-client.cnf とリネーム)
openssl-client.cnf
munakata@mvc:/etc/ssl/private2_for_client_certificate$ diff openssl-client.cnf ../openssl.cnf
73c73
< default_days = 3650 # how long to certify for
---
> default_days = 365 # how long to certify for
185c185
< nsCertType = client, email, objsign
---
> # nsCertType = client, email, objsign
- クライアント証明書用の CSR(= Certificate Signing Request)の発行
- パスフレーズ = magumagumocha
- CN = nanamocha.com
munakata@mvc:/etc/ssl/private2_for_client_certificate$ sudo openssl req -new -config ./openssl-client.cnf -sha256 -keyout cl.key -out cl.csr
Generating a RSA private key
..........................................+++++
......+++++
writing new private key to 'cl.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) [AU]:JP
State or Province Name (full name) [Some-State]:Kanagawa
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Ltd]:IT
Organizational Unit Name (eg, section) []:Admin
Common Name (e.g. server FQDN or YOUR name) []:nanamocha.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
- クライアント証明書の発行 (上記のプライベート認証局でサイン)
JCAN 証明書†
参考 URL†