自己署名証明書の作成
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
*mod_sslのインストール [#i9c40ba7]
# yum install mod_ssl
*秘密鍵の作成 [#w1dcba33]
AES(Advanced Encryption Standard)で鍵を生成する。
# cd /etc/httpd/conf
# openssl genrsa -aes256 2048 > server.key
パスフレーズを聞かれるので適当に入力
password
*公開鍵の作成 [#f14b8f25]
生成した秘密鍵をもとに作成~
Common Nameに *.example.com を指定すればワイルドカードに...
# openssl req -new -key server.key > server.csr
Enter pass phrase for server.key:パスフレーズを入力
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Shinjyuku-ku
Organization Name (eg, company) [Default Company Ltd]:self
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []...
Email Address []:test@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:適当に入力
An optional company name []:
*デジタル証明書の作成 [#x6477566]
100年有効な証明書を作成します。~
SHA-256(SHA-2)で作成したいので、 -sha256 オプションを指定...
指定しないとSHA-1になります。
# openssl x509 -in server.csr -days 36500 -req -signkey ...
Signature ok
subject=/C=JP/ST=Tokyo/L=Shinjyuku-ku/O=self/CN=example....
Getting Private key
Enter pass phrase for server.key:パスフレーズ
*Apacheの設定 [#fe935b51]
書き換えた部分のみ記載
# vi /etc/httpd/conf.d/ssl.conf
DocumentRoot "/home/example/public_html"
ServerName example.com:443
SSLCertificateFile /etc/httpd/conf/server.crt
SSLCertificateKeyFile /etc/httpd/conf/server.key
*Apache起動時のパスフレーズ解除 [#q413e17f]
このままではApacheの起動のたびにパスフレーズの入力が必要...
以下でパスフレーズの入力が不要になります。~
実行する前にバックアップを取っておきましょう。
# cp server.key server.key.org
# openssl rsa -in server.key -out server.key
*ポート確認 [#be4188ad]
# netstat -tanp
# firewall-cmd --zone=public --add-service=https --perma...
# firewall-cmd --reload
# firewall-cmd --list-all
以下は昔書いた内容です。
----
*前提 [#g44d701b]
Apacheは --enable-ssl を付けてインストールしている必要が...
*準備 [#fe3a35af]
# cd /usr/local/apache2/
# mkdir -p ssl/{work,key,cert}
# chmod 700 ssl/key
# DOMAIN_NAME='example.localhost'
# cd ssl
# RAND_VALUE=`vmstat | tail -n 1`
# echo $RAND_VALUE | openssl md5 > work/${DOMAIN_NAME}.r...
# chmod 700 work/${DOMAIN_NAME}.rand
*秘密鍵の生成 [#j8218478]
# openssl genrsa -rand work/${DOMAIN_NAME}.rand -des3 20...
任意に決めたパスフレーズを入力します。~
パスフレーズは忘れてはいけません。
# chmod 700 key/${DOMAIN_NAME}_key.pem
*CSRの生成 [#kdde4872]
# openssl req -new -key key/${DOMAIN_NAME}_key.pem -out ...
さきほどのパスフレーズを入力します。
入力例
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Shibuya
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:system1
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 []:
An optional company name []:
# chmod 700 work/${DOMAIN_NAME}_csr.pem
*証明書の生成 [#r950b983]
例では10年間有効。
# openssl req -x509 -in work/${DOMAIN_NAME}_csr.pem -key...
さきほどのパスフレーズを入力します。
# chmod 700 cert/${DOMAIN_NAME}_crt.self.pem
*パスフレーズの削除 [#j989ab48]
このままだとApache起動時にパスフレーズの入力を求められる...
# openssl rsa -in key/${DOMAIN_NAME}_key.pem -out key/${...
さきほどのパスフレーズを入力します。
*Apacheの設定変更 [#v62a097c]
# vi /usr/local/apache2/conf/httpd.conf
Listen 443
LoadModule ssl_module modules/mod_ssl.so
# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/usr/local/apache2/ssl/cert/exam...
SSLCertificateKeyFile "/usr/local/apache2/ssl/key/ex...
ServerAdmin test@example.com
DocumentRoot "/home/example/public_html"
ServerName example.localhost
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
</VirtualHost>
# /etc/rc.d/init.d/httpd stop
# /etc/rc.d/init.d/httpd start
終了行:
*mod_sslのインストール [#i9c40ba7]
# yum install mod_ssl
*秘密鍵の作成 [#w1dcba33]
AES(Advanced Encryption Standard)で鍵を生成する。
# cd /etc/httpd/conf
# openssl genrsa -aes256 2048 > server.key
パスフレーズを聞かれるので適当に入力
password
*公開鍵の作成 [#f14b8f25]
生成した秘密鍵をもとに作成~
Common Nameに *.example.com を指定すればワイルドカードに...
# openssl req -new -key server.key > server.csr
Enter pass phrase for server.key:パスフレーズを入力
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Shinjyuku-ku
Organization Name (eg, company) [Default Company Ltd]:self
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []...
Email Address []:test@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:適当に入力
An optional company name []:
*デジタル証明書の作成 [#x6477566]
100年有効な証明書を作成します。~
SHA-256(SHA-2)で作成したいので、 -sha256 オプションを指定...
指定しないとSHA-1になります。
# openssl x509 -in server.csr -days 36500 -req -signkey ...
Signature ok
subject=/C=JP/ST=Tokyo/L=Shinjyuku-ku/O=self/CN=example....
Getting Private key
Enter pass phrase for server.key:パスフレーズ
*Apacheの設定 [#fe935b51]
書き換えた部分のみ記載
# vi /etc/httpd/conf.d/ssl.conf
DocumentRoot "/home/example/public_html"
ServerName example.com:443
SSLCertificateFile /etc/httpd/conf/server.crt
SSLCertificateKeyFile /etc/httpd/conf/server.key
*Apache起動時のパスフレーズ解除 [#q413e17f]
このままではApacheの起動のたびにパスフレーズの入力が必要...
以下でパスフレーズの入力が不要になります。~
実行する前にバックアップを取っておきましょう。
# cp server.key server.key.org
# openssl rsa -in server.key -out server.key
*ポート確認 [#be4188ad]
# netstat -tanp
# firewall-cmd --zone=public --add-service=https --perma...
# firewall-cmd --reload
# firewall-cmd --list-all
以下は昔書いた内容です。
----
*前提 [#g44d701b]
Apacheは --enable-ssl を付けてインストールしている必要が...
*準備 [#fe3a35af]
# cd /usr/local/apache2/
# mkdir -p ssl/{work,key,cert}
# chmod 700 ssl/key
# DOMAIN_NAME='example.localhost'
# cd ssl
# RAND_VALUE=`vmstat | tail -n 1`
# echo $RAND_VALUE | openssl md5 > work/${DOMAIN_NAME}.r...
# chmod 700 work/${DOMAIN_NAME}.rand
*秘密鍵の生成 [#j8218478]
# openssl genrsa -rand work/${DOMAIN_NAME}.rand -des3 20...
任意に決めたパスフレーズを入力します。~
パスフレーズは忘れてはいけません。
# chmod 700 key/${DOMAIN_NAME}_key.pem
*CSRの生成 [#kdde4872]
# openssl req -new -key key/${DOMAIN_NAME}_key.pem -out ...
さきほどのパスフレーズを入力します。
入力例
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Shibuya
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:system1
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 []:
An optional company name []:
# chmod 700 work/${DOMAIN_NAME}_csr.pem
*証明書の生成 [#r950b983]
例では10年間有効。
# openssl req -x509 -in work/${DOMAIN_NAME}_csr.pem -key...
さきほどのパスフレーズを入力します。
# chmod 700 cert/${DOMAIN_NAME}_crt.self.pem
*パスフレーズの削除 [#j989ab48]
このままだとApache起動時にパスフレーズの入力を求められる...
# openssl rsa -in key/${DOMAIN_NAME}_key.pem -out key/${...
さきほどのパスフレーズを入力します。
*Apacheの設定変更 [#v62a097c]
# vi /usr/local/apache2/conf/httpd.conf
Listen 443
LoadModule ssl_module modules/mod_ssl.so
# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/usr/local/apache2/ssl/cert/exam...
SSLCertificateKeyFile "/usr/local/apache2/ssl/key/ex...
ServerAdmin test@example.com
DocumentRoot "/home/example/public_html"
ServerName example.localhost
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined
</VirtualHost>
# /etc/rc.d/init.d/httpd stop
# /etc/rc.d/init.d/httpd start
ページ名: