2008年4月17日木曜日

WebをSSL暗号化するためのopenssl の設定 メモ

WebをSSL暗号化するためのopenssl の設定につき、以下のサイトを参考にさせていただいています。
http://nai.homelinux.net/ssl.html
http://www.kazutoyo.com/ubuntu/


設定の流れ
まずデフォルトの項目を設定しておく
# nano /etc/ssl/openssl.cnfにて編集する   
# nano /etc/ssl/openssl.cnf  
default_days = 3650   # how long to certify for  有効期限の変更を10年にする
dir = /etc/ssl/CA     # Where everything is kept     
countryName= JP                                             
stateOrProvinceName= 県名                                          
localityName =市町村名                                    
organizationName=組織名                                     
organizationalUnitName= Kaihatu-bumatsuzak                               
commonName= 192.168.*.**(IPアドレス)                     
emailAddres=***@*****(連絡用メールアドレス)                         

[ usr_cert ]                                                      
# This is OK for an SSL server.                                        
nsCertType = server  コメントアウト#を外す                

[ v3_ca ]                                                        
# Some might want this also                                           
nsCertType = sslCA, emailCA  コメントアウト#を外す
とりあえずここまで保存しておく
以上

次に各種ディレクトリ、ファイルを必要なだけ作成しておく。
# cd /etc/ssl
# mkdir -m 755 CA
# cd /etc/ssl/CA  以下ここで作業する

# cat /dev/null > index.txt                                            
# echo '01' > serial                                                  
# echo '01' > crlnumber                                              
# mkdir private
# chmod 700 private
# mkdir newcerts
# mkdir crl
# mkdir certs
以上まで

# cd /etc/ssl/CAの下で作業する。
秘密鍵の作成
# openssl genrsa -out private/cakey.pem 1024
Generating RSA private key, 1024 bit long modulus
.....++++++
................................++++++
e is 65537 (0x10001)

次に、秘密鍵を用いて証明書を作成する
-daysオプションを用いて有効期限を10年と設定しておく

# openssl req -new -x509 -days 3650 -key private/cakey.pem -out cacert.pem

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]:県名
Locality Name (eg, city) []:市町村
Organization Name (eg, company) [Internet Widgits Pty Ltd]:組織名
Organizational Unit Name (eg, section) []:Kaihatu-bu
Common Name (eg, YOUR name) []:192.168.*.**
Email Address []:***@*****
以上





0 件のコメント: