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

2015/09/14

Tips サーバー テクノロジー

t f B! P L

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

#nginxのインストール $ apt-get install nginx

鍵と証明書の作成

秘密鍵の作成

$ 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/

nginxの設定

# /etc/nginx/conf.d/ssl.conf の編集 ----- server { listen 443 ssl; server_name _; ssl on; ssl_certificate /etc/ssl/private/server.crt; ssl_certificate_key /etc/ssl/private/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #ssl_protocols SSLv2 SSLv3 TLSv1; #ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; #ssl_prefer_server_ciphers on; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/share/nginx/html; index index.html index.htm; } } -----

nginxの再起動

$ /etc/init.d/nginx restart

確認

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

人気の投稿

このブログを検索

ごあいさつ

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

ブログ アーカイブ