[server] オレオレ証明書の登録方法メモ  #Debian 8.1 + Apache + mod-ssl 編

2015年9月12日

Tips サーバー テクノロジー

基本モジュールインストール

#apacheのインストール $ apt-get install apache2 #open-sslのインストール $ apt-get install openssl #open-sslを有効化する $ a2enmod ssl See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates. To activate the new configuration, you need to run: service apache2 restart

鍵と証明書の作成

秘密鍵の作成

$ openssl genrsa -aes128 1024 > server.key Generating RSA private key, 1024 bit long modulus .......++++++ .......................++++++ e is 65537 (0x10001) Enter pass phrase: ***** Verifying - Enter pass phrase: ***** Verify failure User interface error 139960119879584:error:0906906F:PEM routines:PEM_ASN1_write_bio:read key:pem_lib.c:382:

秘密鍵のパスワードを削除

$ openssl rsa -in server.key -out server.key Enter pass phrase for server.key:***** writing RSA key

公開鍵の作成

$ openssl req -new -key server.key > server.csr Enter pass phrase for server.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) [XX]:*** State or Province Name (full name) []:*** Locality Name (eg, city) [Default City]:*** Organization Name (eg, company) [Default Company Ltd]:*** Organizational Unit Name (eg, section) []:*** 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 []:

証明書の作成

$ openssl x509 -in server.csr -days 365 -req -signkey server.key > server.crt Signature ok subject=/C=***/ST=***/L=***/O=***/OU=*** Getting Private key Enter pass phrase for server.key: <font color="red">***</font>

証明書を定位置に移動

$ mv server.* /etc/ssl/private/

Apacheの設定

# ssl.confのシンボリック作成 $ ln -s /etc/apache/site_available/default-ssl.conf # /etc/apache/site_enabled/default-ssl.conf の編集 (32,33行目あたり) #コメントアウト ##SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem ##SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key #追記 SSLCertificateFile /etc/ssl/private/server.crt SSLCertificateKeyFile /etc/ssl/private/server.key

apacheの再起動

$ /etc/init.d/apache2 restart

確認

https://***/ へアクセスしてみる。 この画面になれば成功!

このブログを検索

ごあいさつ

このWebサイトは、独自思考で我が道を行くユゲタの少し尖った思考のTechブログです。 毎日興味がどんどん切り替わるので、テーマはマルチになっています。 もしかしたらアイデアに困っている人の助けになるかもしれません。