Triplex Systemsの開発メモです。開発の手順・開発に関するTipsをまとめます。

作業の準備

  • ApacheをSSL対応にする
# yum install mod_ssl
  • 必要なディレクトリの作成
# mkdir /etc/httpd/ssl
# mkdir /etc/httpd/ssl/ssl.crl
# touch /etc/httpd/ssl/ssl.crl/cert.crl
  • プログラムのコピー
# cp -p /etc/pki/tls/misc/CA /etc/httpd/ssl/
# cp -p /etc/pki/tls/openssl.cnf /etc/httpd/ssl/
  • /etc/httpd/ssl/CAを編集
DAYS="-days 365" → DAYS="-days 1825"
CATOP=../../CA → CATOP=/etc/httpd/ssl/selfCA
  • /etc/httpd/ssl/openssl.cnfを編集
dir = ../../CA → dir = ./selfCA
basicConstraints=CA:FALSE → basicConstraints=CA:TRUE

認証局を作成

# cd /etc/httpd/ssl
# ./CA -newca
CA certificate filename (or enter to create) ← Enter
Enter PEM pass phrase: ←CAのパスワード
Verifying - Enter PEM pass phrase: ←CAのパスワード(確認)
Country Name (2 letter code) [GB]: ←国名(JP)
State or Province Name (full name) [Berkshire]: ←都道府県名
Locality Name (eg, city) [Newbury]: ←市町村名
Organization Name (eg, company) [My Company Ltd]: ←組織名・会社名
Organizational Unit Name (eg, section) []: ←部署名
Common Name (eg, your name or your server's hostname) []: ←サーバのホスト名
Email Address []: ←メールアドレス
A challenge password []: ← Enter
An optional company name []: ← Enter
Enter pass phrase for /etc/httpd/ssl/selfCA/private/./cakey.pem: ←CAのパスワード(確認)
# openssl rsa -in ./selfCA/private/cakey.pem -out ./selfCA/private/cakey.pem
Enter pass phrase for ./selfCA/private/cakey.pem: ←CAのパスワード(確認)
# echo '00' > ./selfCA/crlnumber
# openssl ca -config openssl.cnf -gencrl -out ./selfCA/crl.pem

サーバ証明書を作成

# cd /etc/httpd/ssl
# vi /etc/pki/tls/openssl.cnf
basicConstraints=CA:TRUE → basicConstraints=CA:FALSE
# openssl genrsa -out ./server.key 2048
# openssl req -sha256 -new -days 1825 -key ./server.key -out ./server.csr
Enter pass phrase for ./server.key: ←サーバ証明書のパスワード(確認)
Country Name (2 letter code) [GB]: ←国名(JP)
State or Province Name (full name) [Berkshire]: ←都道府県名
Locality Name (eg, city) [Newbury]: ←市町村名
Organization Name (eg, company) [My Company Ltd]: ←組織名・会社名
Organizational Unit Name (eg, section) []: ←部署名
Common Name (eg, your name or your server's hostname) []: ←サーバのホスト名
Email Address []: ←メールアドレス
A challenge password []: ← Enter
An optional company name []: ← Enter
# openssl ca -days 1825 -in server.csr -keyfile ./selfCA/private/cakey.pem \
-cert ./selfCA/cacert.pem -out server.crt
Sign the certificate? [y/n]: ← y
1 out of 1 certificate requests certified, commit? [y/n] ← y

クライアント証明書を作成

# cd /etc/httpd/ssl
# ./CA -newreq
# ./CA -sign


# openssl genrsa -des3 -out ./client.key 1024
Enter pass phrase for client.key: ←クライアント証明書のパスワード
Verifying - Enter pass phrase for client.key: ←クライアント証明書のパスワード(確認)
# openssl rsa -in ./client.key -out ./client.key
Enter pass phrase for client.key: ←クライアント証明書のパスワード(確認)
# openssl req -new -days 1825 -key ./client.key -out ./client.csr
Enter pass phrase for ./server.key: ←サーバ証明書のパスワード(確認)
Country Name (2 letter code) [GB]: ←国名(JP)
State or Province Name (full name) [Berkshire]: ←都道府県名
Locality Name (eg, city) [Newbury]: ←市町村名
Organization Name (eg, company) [My Company Ltd]: ←組織名・会社名
Organizational Unit Name (eg, section) []: ←部署名
Common Name (eg, your name or your server's hostname) []: ←クライアント名
Email Address []: ←メールアドレス
A challenge password []: ← Enter
An optional company name []: ← Enter
# openssl ca -days 1825 -in ./client.csr -out ./client.crt
Sign the certificate? [y/n]: ← y
1 out of 1 certificate requests certified, commit? [y/n] ← y
# openssl pkcs12 -export -in ./client.crt -inkey ./client.key \
-certfile ./selfCA/cacert.pem -out ./client.p12
Enter Export Password: ← Enter
Verifying - Enter Export Password: ← Enter

Apacheの設定

  • /etc/httpd/conf.d/ssl.conf を編集
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
→ SSLCertificateFile /etc/httpd/ssl/server.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
→ SSLCertificateKeyFile /etc/httpd/ssl/server.key
SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
←SSLCACertificateFile /etc/httpd/ssl/selfCA/cacert.pem
#SSLVerifyClient require
→ SSLVerifyClient require
#SSLVerifyDepth 10
→ SSLVerifyDepth 1

このページへのコメント

jtfgfU I truly appreciate this article post.Really thank you! Really Great.

0
Posted by awesome things! 2014年01月23日(木) 15:08:24 返信

BtzQ8h Thanks again for the blog.Much thanks again. Want more.

0
Posted by stunning seo guys 2014年01月20日(月) 14:41:59 返信

aBjdim wow, awesome article post.Really looking forward to read more.

0
Posted by stunning seo guys 2013年12月31日(火) 17:51:45 返信

F1Iubi Say, you got a nice article.Really thank you! Awesome.

0
Posted by check this out 2013年12月20日(金) 12:54:46 返信

kCGYLa <a href="http://ocehyzhudwgo.com/">ocehyzhudwgo</a>, [url=http://guonjuuyyfvd.com/]guonjuuyyfvd[/url], [link=http://dpqmegjichwn.com/]dpqmegjichwn[/link], http://ststpseedfna.com/

0
Posted by eorajcijrdj 2013年11月20日(水) 22:01:41 返信

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

管理人/副管理人のみ編集できます