31
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Apache+OpenSSLで簡単に自己認証したい

Last updated at Posted at 2014-05-15

SSL接続のテストの為におれおれ認証用に証明書と鍵ペアをできるだけ簡単に作る。

##ワンライナー

openssl genrsa -out server.key 2048 ; openssl req -new -key server.key -out server.csr -subj '/C=JP/ST=Tokyo/L=Tokyo/O=Example Ltd./OU=Web/CN=example.com' ; openssl x509 -in server.csr -days 3650 -req -signkey server.key > server.crt

/C=JP/ST=Tokyo/L=Tokyo/O=Example Ltd./OU=Web/CN=example.com らへんを任意に編集してください

カレントディレクトリにserver.key(秘密鍵) と server.crt (証明書)ができるのでそれを使います。

これで終わり

##上記コマンドを1行づつ説明すると・・・

秘密鍵(server.key)の作成 (パスフレーズなし)

openssl genrsa -out server.key 2048

公開鍵(server.csr)の作成

openssl req -new -key server.key -out server.csr -subj '/C=JP/ST=Tokyo/L=Tokyo/O=Example Ltd./OU=Web/CN=example.com'

公開鍵を使って証明書(server.crt)の作成

openssl x509 -in server.csr -days 3650 -req -signkey server.key > server.crt

##Apacheで使う場合

server.key (秘密鍵)とserver.crt (証明書) をApacheに設定

conf/extra/httpd-ssl.conf
SSLCertificateKeyFile /path/to/server.key
SSLCertificateFile /path/to/ssl/server.crt
31
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?