Pippi Life

主に仕事に関連するITのことや、プライベートもちょいちょい書きます。

おれおれ証明書の作り方。

おれおれ証明書の作り方です。 開発だと結構使うかなーと思います。

自サーバーを証明機関にする方法もあるけど、 今回はそうじゃない方法で。

$ cd /etc/httpd/conf
$ mkdir ssl
$ cd ssl
$ openssl genrsa -des3 -out server.key 2048 -sha256
$ openssl req -new -sha256 -key server.key -out server.csr -subj "/C=JP/ST=Tokyo/L=Minato-ku/OU=/O=ToshibaHC/CN=creage.com"


Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Minato-ku
Organization Name (eg, company) [Default Company Ltd]: CBC.
Organizational Unit Name (eg, section) []:Cresco Ltd.
Common Name (eg, your name or your server's hostname) []:ec2-xx-xxx-xxx-xx.ap-northeast-1.compute.amazonaws.com       ←DNS名
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:


$ cp server.key server.key.bak
$ openssl rsa -in server.key -out server.key



$ openssl x509 -req -sha256 -signkey  server.key < server.csr > server.crt 
Signature ok
subject=/C=JP/ST=Tokyo/L=Minato-ku/O= CBC./OU=Cresco Ltd./CN=ec2-xx-xxx-xxx-xx.ap-northeast-1.compute.amazonaws.com
Getting Private key

[root@ip-10-0-22-10 conf]# ls -l
合計 52
-rw-r-----. 1 root root 12127  9月 22 13:25 httpd.conf
-rw-r-----. 1 root root 12127 10月 15 15:23 httpd.conf.org
-rw-r-----. 1 root root 13077  8月 25 03:12 magic
-rw-r--r--. 1 root root  1415 10月 15 22:01 server.crt
-rw-r--r--. 1 root root  1110 10月 15 22:00 server.csr
-rw-r--r--. 1 root root  1679 10月 15 21:57 server.key

作成したcrtとkeyをsslに設定して完成。 crtはIEに登録しておきましょう。 「信頼できるルート証明機関」に登録でよかったはず。うろ覚えだけど。