HomeServer17B
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#contents()
** 考え方 [#icd86f00]
- クライアント証明には(自己認証局であっても)CA の裏付け...
- クライアント用の証明書の作成(発行)には認証局の証明書...
- クライアント証明書には &color(red){SSLCACertificateFile...
- &color(red){SSLCACertificateFile = CA中間証明書 + roo...
- kgb.hmuna.com には第三者証明書が登録済み
-- サーバー証明書 [&color(blue){SSLCertificateFile};]
-- 秘密鍵 [&color(blue){SSLCertificateKeyFile};]
-- 中間証明書[&color(blue){SSLCertificateChainFile};]
# Server Certificate:
SSLCertificateFile /etc/ssl/official4/kgb_hmuna_co...
# Server Private Key:
SSLCertificateKeyFile /etc/ssl/official4/wiki.hmuna.c...
# Server Certificate Chain:
SSLCertificateChainFile /etc/ssl/official4/kgb_hmuna_co...
# Client Certificate: (official CA (COMODO) to generate ...
SSLCACertificateFile /etc/ssl/official4A_for_client_...
SSLVerifyClient none
- だが CA局の証明書と鍵は無い
-- 認証局の証明書() =
-- 認証局の鍵 () =
- [[&color(red){登録済みの公式 &color(red){クライアント証...
-- 使えない、まだクライアント証明が入っていないのだから
- SSLCertificateChainFile と SSLCACertificateFile の違い
-- SSLCertificateChainFile ディレクティブ:サーバー証明書...
--- &color(red){Apache2.4.8以降はSSLCertificateChainFile...
-- SSLCACertificateFile ディレクティブ:クライアント証明...
*** openssl バージョンの確認 [#b5a07749]
munakata@mvc:~$ openssl version -a
OpenSSL 1.1.1 11 Sep 2018
built on: Thu Jun 20 17:36:28 2019 UTC
platform: debian-amd64
options: bn(64,64) rc4(8x,int) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wal...
-fstack-protector-strong -Wformat -Werror=format-securit...
DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_AS...
-DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -D...
Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-1.1"
Seeding source: os-specific
*** Apache バージョン確認 [#l740b5ac]
munakata@mvc:~$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2019-08-26T13:41:23
- [[Apache 2.4.8 から中間CA証明書を指定するSSLCertificate...
*** Apache mod-ssl の確認 [#t5a30443]
munakata@mvc:~$ sudo apache2ctl -M | grep ssl
ssl_module (shared)
munakata@mvc:~$ cat /etc/apache2/mods-available/ssl.load
# Depends: setenvif mime socache_shmcb
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
munakata@mvc:~$ file /usr/lib/apache2/modules/mod_ssl.so
/usr/lib/apache2/modules/mod_ssl.so: ELF 64-bit LSB shar...
*** kgb.hmuna.com 証明書情報 [#g2979cc5]
- COMODO により発行されているもの
- &ref(kgb_cirt.jpg);
*** COMODO の SSLCACertificateFile 対応 [#d8921c69]
- [[SSLCACertificateFileディレクティブの代替ディレクティ...
-- &color(red){SSLCACertificateFileの代わりにSSLCertifica...
** クライアント証明書の作成 [#o285d5a9]
*** クライアント証明書の作成に必要な情報、操作などから方...
- クライアント鍵(key)の作成(自己完結)
openssl genrsa -des3 -out example_com-client1.key 1024
- 証明書への署名要求(csr)の作成(自己完結)
openssl req -new -sha256 -key example_com-client1.key -o...
- openssl.cnf を一部変更した openssl-client.cnf を作成(...
[my_ca_default]
.
.
x509_extensions = usr_cert # 追加
.
.
[ usr_cert ] # 追加
basicConstraints=CA:FALSE # 追加
nsCertType = client, email # 追加
- 作成した openssl-client.cnf を使用して CAで署名(&color...
sudo openssl ca -config ./openssl-client.cnf -md sha256 ...
-- openssl-client.cnf(自己完結)
-- &color(red){myCA/myca.crt(CA局の情報が必要 crt ファイ...
--- &color(red){''違う! 既にあるのはサーバー証明書。 CA...
-- myca.key(既に自分で作った秘密鍵がある ・・・ だから自己...
-- example_com-client1.crt(生成するクライアント証明書)
-- example_com-client1.csr(自己完結)
*** オレオレ CA を使ったクライアント証明書の作成 [#x63d13...
- [[[Apache+openSSLでクライアント認証 - 闘うITエンジニア...
- /etc/ssl/private_CA にファイルを生成していく
munakata@mvc:/etc/ssl$ sudo mkdir private_CA
munakata@mvc:/etc/ssl$ cd private_CA
munakata@mvc:/etc/ssl/private_CA$ sudo mkdir private
munakata@mvc:/etc/ssl/private_CA$ sudo mkdir newcerts
munakata@mvc:/etc/ssl/private_CA$ sudo chmod 700 private/
munakata@mvc:/etc/ssl/private_CA$ sudo sh -c 'echo 01>se...
munakata@mvc:/etc/ssl/private_CA$ cat serial
0
munakata@mvc:/etc/ssl/private_CA$ sudo touch index.txt
munakata@mvc:/etc/ssl/private_CA$ ls -l
合計 12
-rw-r--r-- 1 root root 0 9月 16 15:08 index.txt
drwxr-xr-x 2 root root 4096 9月 16 15:02 newcerts
drwx------ 2 root root 4096 9月 16 15:02 private
-rw-r--r-- 1 root root 3 9月 16 15:04 serial
- 自己認証 CA 局を作成
munakata@mvc:/etc/ssl/private_CA$ sudo openssl req -new ...
Generating a RSA private key
..........+++++
........................+++++
writing new private key to 'private/myca.key'
Enter PEM pass phrase: <----------------- bobbob274mocha
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will...
into your certificate request.
What you are about to enter is what is called a Distingu...
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) [Kanagawa]:Kanagawa
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Lt...
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:kgb.hmuna...
Email Address []:
-- 有効期間は 10年 とした
-- &color(red){パスフレーズは bobbob274mocha};
- openssl.cnf ファイルをクライアント証明書用に編集
-- &ref(client_openssl.cnf);
- クライアント証明書鍵の発行
munakata@mvc:/etc/ssl/private_CA$ sudo openssl genrsa -d...
Generating RSA private key, 1024 bit long modulus (2 pri...
...........................................................
......+++++
e is 65537 (0x010001)
Enter pass phrase for kgb_hmuna-client1.key:
Verifying - Enter pass phrase for kgb_hmuna-client1.key:
-- &color(red){パスフレーズは magumagu274};
- 証明書への署名要求の作成
munakata@mvc:/etc/ssl/private_CA$ sudo openssl req -new ...
Enter pass phrase for kgb_hmuna-client1.key: <----------...
You are about to be asked to enter information that will...
into your certificate request.
What you are about to enter is what is called a Distingu...
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]:
State or Province Name (full name) [Kanagawa]:
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Lt...
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:kgb.hmuna...
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <------------------ そのままリ...
An optional company name []:
- クライアント証明書の発行
munakata@mvc:/etc/ssl/private_CA$ sudo sh -c 'openssl ca...
Using configuration from ./client_openssl.cnf
Enter pass phrase for ./private/myca.key:
Can't open ./index.txt.attr for reading, No such file or...
139890709250496:error:02001002:system library:fopen:No s...
139890709250496:error:2006D080:BIO routines:BIO_new_file...
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Sep 16 07:26:53 2019 GMT
Not After : Sep 13 07:26:53 2029 GMT
Subject:
countryName = JP
stateOrProvinceName = Kanagawa
organizationName = hmuna
organizationalUnitName = IT
commonName = kgb.hmuna.com
X509v3 extensions:
Netscape Cert Type:
SSL Client, S/MIME
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
58:AB:C3:DC:9D:50:59:15:A6:42:2E:68:C7:8...
X509v3 Authority Key Identifier:
keyid:D9:E6:21:6D:2C:03:EE:80:7E:44:85:1...
Certificate is to be certified until Sep 13 07:26:53 202...
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
- ファイルの状態
munakata@mvc:/etc/ssl/private_CA$ sudo tree
.
├── client_openssl.cnf
├── crl
├── index.txt
├── index.txt.attr
├── index.txt.old
├── kgb_hmuna-client1.crt <--- CA 局の証明書:これを Apa...
├── kgb_hmuna-client1.csr
├── kgb_hmuna-client1.key
├── myca.crt
├── newcerts
│ └── 01.pem <-------------- 生成されたクライアント証...
├── private
│ └── myca.key <----------- CA 局の鍵ファイル
├── serial
└── serial.old
-- CA 局の証明書 = &ref(kgb_hmuna-client1.crt);
- クライアント証明書を PKCS#12 形式に変換
munakata@mvc:/etc/ssl/private_CA$ sudo openssl pkcs12 -e...
Enter pass phrase for kgb_hmuna-client1.key:
Enter Export Password: <---------------- magumagu274
Verifying - Enter Export Password: <----- magumagunanamo...
-- &color(red){export password = magumagunanamocha};
-- &ref(kgb_hmuna-client1.p12);
** 補足情報 [#w8a6747e]
*** 参考 URL [#cdbc3578]
- CA 局作成関連
-- [[Ubuntu 18.04 LTS で OpenSSL を使ったプライベート認証...
-- [[https://server-setting.info/centos/private-ca-cert.h...
-- [[OpenSSLで自己認証局を作る:https://kgb.hmuna.com/inde...
- クライアント証明書関連
-- [[☆ Apache+openSSLでクライアント認証:https://www.magat...
-- [[クライアント証明書を要求するサイトの構築(Apache+Ope...
-- [[Apacheでのクライアント証明書利用設定入門:https://rms...
-- [[Client Authentication and Access Control (mod_ssl ...
- 一般
-- [[RSA鍵、証明書のファイルフォーマットについて:https://...
終了行:
#contents()
** 考え方 [#icd86f00]
- クライアント証明には(自己認証局であっても)CA の裏付け...
- クライアント用の証明書の作成(発行)には認証局の証明書...
- クライアント証明書には &color(red){SSLCACertificateFile...
- &color(red){SSLCACertificateFile = CA中間証明書 + roo...
- kgb.hmuna.com には第三者証明書が登録済み
-- サーバー証明書 [&color(blue){SSLCertificateFile};]
-- 秘密鍵 [&color(blue){SSLCertificateKeyFile};]
-- 中間証明書[&color(blue){SSLCertificateChainFile};]
# Server Certificate:
SSLCertificateFile /etc/ssl/official4/kgb_hmuna_co...
# Server Private Key:
SSLCertificateKeyFile /etc/ssl/official4/wiki.hmuna.c...
# Server Certificate Chain:
SSLCertificateChainFile /etc/ssl/official4/kgb_hmuna_co...
# Client Certificate: (official CA (COMODO) to generate ...
SSLCACertificateFile /etc/ssl/official4A_for_client_...
SSLVerifyClient none
- だが CA局の証明書と鍵は無い
-- 認証局の証明書() =
-- 認証局の鍵 () =
- [[&color(red){登録済みの公式 &color(red){クライアント証...
-- 使えない、まだクライアント証明が入っていないのだから
- SSLCertificateChainFile と SSLCACertificateFile の違い
-- SSLCertificateChainFile ディレクティブ:サーバー証明書...
--- &color(red){Apache2.4.8以降はSSLCertificateChainFile...
-- SSLCACertificateFile ディレクティブ:クライアント証明...
*** openssl バージョンの確認 [#b5a07749]
munakata@mvc:~$ openssl version -a
OpenSSL 1.1.1 11 Sep 2018
built on: Thu Jun 20 17:36:28 2019 UTC
platform: debian-amd64
options: bn(64,64) rc4(8x,int) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wal...
-fstack-protector-strong -Wformat -Werror=format-securit...
DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_AS...
-DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -D...
Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-1.1"
Seeding source: os-specific
*** Apache バージョン確認 [#l740b5ac]
munakata@mvc:~$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2019-08-26T13:41:23
- [[Apache 2.4.8 から中間CA証明書を指定するSSLCertificate...
*** Apache mod-ssl の確認 [#t5a30443]
munakata@mvc:~$ sudo apache2ctl -M | grep ssl
ssl_module (shared)
munakata@mvc:~$ cat /etc/apache2/mods-available/ssl.load
# Depends: setenvif mime socache_shmcb
LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
munakata@mvc:~$ file /usr/lib/apache2/modules/mod_ssl.so
/usr/lib/apache2/modules/mod_ssl.so: ELF 64-bit LSB shar...
*** kgb.hmuna.com 証明書情報 [#g2979cc5]
- COMODO により発行されているもの
- &ref(kgb_cirt.jpg);
*** COMODO の SSLCACertificateFile 対応 [#d8921c69]
- [[SSLCACertificateFileディレクティブの代替ディレクティ...
-- &color(red){SSLCACertificateFileの代わりにSSLCertifica...
** クライアント証明書の作成 [#o285d5a9]
*** クライアント証明書の作成に必要な情報、操作などから方...
- クライアント鍵(key)の作成(自己完結)
openssl genrsa -des3 -out example_com-client1.key 1024
- 証明書への署名要求(csr)の作成(自己完結)
openssl req -new -sha256 -key example_com-client1.key -o...
- openssl.cnf を一部変更した openssl-client.cnf を作成(...
[my_ca_default]
.
.
x509_extensions = usr_cert # 追加
.
.
[ usr_cert ] # 追加
basicConstraints=CA:FALSE # 追加
nsCertType = client, email # 追加
- 作成した openssl-client.cnf を使用して CAで署名(&color...
sudo openssl ca -config ./openssl-client.cnf -md sha256 ...
-- openssl-client.cnf(自己完結)
-- &color(red){myCA/myca.crt(CA局の情報が必要 crt ファイ...
--- &color(red){''違う! 既にあるのはサーバー証明書。 CA...
-- myca.key(既に自分で作った秘密鍵がある ・・・ だから自己...
-- example_com-client1.crt(生成するクライアント証明書)
-- example_com-client1.csr(自己完結)
*** オレオレ CA を使ったクライアント証明書の作成 [#x63d13...
- [[[Apache+openSSLでクライアント認証 - 闘うITエンジニア...
- /etc/ssl/private_CA にファイルを生成していく
munakata@mvc:/etc/ssl$ sudo mkdir private_CA
munakata@mvc:/etc/ssl$ cd private_CA
munakata@mvc:/etc/ssl/private_CA$ sudo mkdir private
munakata@mvc:/etc/ssl/private_CA$ sudo mkdir newcerts
munakata@mvc:/etc/ssl/private_CA$ sudo chmod 700 private/
munakata@mvc:/etc/ssl/private_CA$ sudo sh -c 'echo 01>se...
munakata@mvc:/etc/ssl/private_CA$ cat serial
0
munakata@mvc:/etc/ssl/private_CA$ sudo touch index.txt
munakata@mvc:/etc/ssl/private_CA$ ls -l
合計 12
-rw-r--r-- 1 root root 0 9月 16 15:08 index.txt
drwxr-xr-x 2 root root 4096 9月 16 15:02 newcerts
drwx------ 2 root root 4096 9月 16 15:02 private
-rw-r--r-- 1 root root 3 9月 16 15:04 serial
- 自己認証 CA 局を作成
munakata@mvc:/etc/ssl/private_CA$ sudo openssl req -new ...
Generating a RSA private key
..........+++++
........................+++++
writing new private key to 'private/myca.key'
Enter PEM pass phrase: <----------------- bobbob274mocha
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will...
into your certificate request.
What you are about to enter is what is called a Distingu...
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) [Kanagawa]:Kanagawa
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Lt...
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:kgb.hmuna...
Email Address []:
-- 有効期間は 10年 とした
-- &color(red){パスフレーズは bobbob274mocha};
- openssl.cnf ファイルをクライアント証明書用に編集
-- &ref(client_openssl.cnf);
- クライアント証明書鍵の発行
munakata@mvc:/etc/ssl/private_CA$ sudo openssl genrsa -d...
Generating RSA private key, 1024 bit long modulus (2 pri...
...........................................................
......+++++
e is 65537 (0x010001)
Enter pass phrase for kgb_hmuna-client1.key:
Verifying - Enter pass phrase for kgb_hmuna-client1.key:
-- &color(red){パスフレーズは magumagu274};
- 証明書への署名要求の作成
munakata@mvc:/etc/ssl/private_CA$ sudo openssl req -new ...
Enter pass phrase for kgb_hmuna-client1.key: <----------...
You are about to be asked to enter information that will...
into your certificate request.
What you are about to enter is what is called a Distingu...
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]:
State or Province Name (full name) [Kanagawa]:
Locality Name (eg, city) []:Yokohama
Organization Name (eg, company) [Internet Widgits Pty Lt...
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:kgb.hmuna...
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <------------------ そのままリ...
An optional company name []:
- クライアント証明書の発行
munakata@mvc:/etc/ssl/private_CA$ sudo sh -c 'openssl ca...
Using configuration from ./client_openssl.cnf
Enter pass phrase for ./private/myca.key:
Can't open ./index.txt.attr for reading, No such file or...
139890709250496:error:02001002:system library:fopen:No s...
139890709250496:error:2006D080:BIO routines:BIO_new_file...
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Sep 16 07:26:53 2019 GMT
Not After : Sep 13 07:26:53 2029 GMT
Subject:
countryName = JP
stateOrProvinceName = Kanagawa
organizationName = hmuna
organizationalUnitName = IT
commonName = kgb.hmuna.com
X509v3 extensions:
Netscape Cert Type:
SSL Client, S/MIME
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
58:AB:C3:DC:9D:50:59:15:A6:42:2E:68:C7:8...
X509v3 Authority Key Identifier:
keyid:D9:E6:21:6D:2C:03:EE:80:7E:44:85:1...
Certificate is to be certified until Sep 13 07:26:53 202...
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
- ファイルの状態
munakata@mvc:/etc/ssl/private_CA$ sudo tree
.
├── client_openssl.cnf
├── crl
├── index.txt
├── index.txt.attr
├── index.txt.old
├── kgb_hmuna-client1.crt <--- CA 局の証明書:これを Apa...
├── kgb_hmuna-client1.csr
├── kgb_hmuna-client1.key
├── myca.crt
├── newcerts
│ └── 01.pem <-------------- 生成されたクライアント証...
├── private
│ └── myca.key <----------- CA 局の鍵ファイル
├── serial
└── serial.old
-- CA 局の証明書 = &ref(kgb_hmuna-client1.crt);
- クライアント証明書を PKCS#12 形式に変換
munakata@mvc:/etc/ssl/private_CA$ sudo openssl pkcs12 -e...
Enter pass phrase for kgb_hmuna-client1.key:
Enter Export Password: <---------------- magumagu274
Verifying - Enter Export Password: <----- magumagunanamo...
-- &color(red){export password = magumagunanamocha};
-- &ref(kgb_hmuna-client1.p12);
** 補足情報 [#w8a6747e]
*** 参考 URL [#cdbc3578]
- CA 局作成関連
-- [[Ubuntu 18.04 LTS で OpenSSL を使ったプライベート認証...
-- [[https://server-setting.info/centos/private-ca-cert.h...
-- [[OpenSSLで自己認証局を作る:https://kgb.hmuna.com/inde...
- クライアント証明書関連
-- [[☆ Apache+openSSLでクライアント認証:https://www.magat...
-- [[クライアント証明書を要求するサイトの構築(Apache+Ope...
-- [[Apacheでのクライアント証明書利用設定入門:https://rms...
-- [[Client Authentication and Access Control (mod_ssl ...
- 一般
-- [[RSA鍵、証明書のファイルフォーマットについて:https://...
ページ名: