Diary

Self training to output someting

SSL認証(オレオレ証明書)

オレオレ証明書を作成し、https接続をした時の手順

 

参考ホームページ

http://d.hatena.ne.jp/ozuma/20130511/1368284304

 

前準備

yum -y install openssl openssl-devel

 

必要となるファイル

秘密鍵(自分の管理するサーバ)(PrivateKey)

証明書署名要求(CSR

サーバ証明書(CRT)

 

手順(オレオレ証明書では、2.3.を自分でやってしまう)

1.サーバ管理者が秘密鍵ファイルを作成する

2.サーバ管理者が秘密鍵ファイルから、公開鍵と、秘密鍵のハッシュを組み合わせて、証明書署名要求ファイルを作成する。サーバ管理者はこの証明書署名要求ファイルを認証局に送付する。

3.認証局は自分の秘密鍵で証明書署名要求ファイルに署名してサーバ証明書を作成し、返却する。

 

1.秘密鍵の作成

openssl genrsa 2048 > server.key

 

2.証明書署名要求の作成

openssl rsq -new server.key > server.csr

ここはエンター連打

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]:
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)
:
Common Name (e.g. server FQDN or YOUR name) :
Email Address
:

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

 

3.サーバ証明書の作成

通常ならば、server.csr認証局(CA)に送り署名をもらう

オレオレでは、自分自身で公開鍵を記入する

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

※オプション(-days)は有効期限を設定できる

 

SSL認証ファイルをApacheへ設定

Apache を使用している場合は、mod-sslをインストールする

yum -y mod-ssl

 

/etc/httpd/conf.d/ssl.confに追加記載

SSLCertificateFile /認証局のファイルのパス
SSLCertificateKeyFile /秘密鍵ファイルのパス

 

Apache のリスタート

servive httpd restart