edo1z blog

プログラミングなどに関するブログです

SSL証明書の設定(AWS)

何をやるかちょっと忘れた。

参考: http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/InstallCert.html#InstallSSL-managing-server-certs

sshでサーバに入ります。 opensslが入ってるか確認します。

sudo yum update openssl

プライベートキーを作成します。

openssl genrsa 2048 > private-key.pem

CSR(証明書署名要求)を作成する。

openssl req -new -key private-key.pem -out csr.pem
Country Nameは、日本の場合、JP
State or Province Nameは、都道府県なので、Tokyoとか。
Locality Name (eg, city)は、市区町村。Shibuya-kuとか。
Organization Nameは、会社名。Logicky Inc.など。
Organizational Unit Nameは、組織名(オプション)。
Common Nameは、ドメイン。logicky.comなど。(ワイルドカードを使ってサブドメインに対応させる場合は、*.logicky.comとする)
Email Addressは、メアド(オプション。空でいいらしい。)

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: これは、空でいいらしい。
An optional company name []: これは、空でいいらしい。

これで完成。

netowl.jpというところでSSL証明書を買ったんだけど、CSR入力後にSSL証明書発行したら、承認メールが送られてくるようになっていて、SSL証明を使うドメインのメールアドレスに承認メールが送られてくるので、メール受信可能な状態にしないといけない。AWSでメール受信設定するのもめんどくさいので、google mailを使うことにした。

証明書を発行したら、AWSのiamというのにアップロードしたら便利らしい。iamとか使わなくてもこの前で来たけどやってみる。

aws iam upload-server-certificate --server-certificate-name certificate_object_name --certificate-body file://public_key_certificate_file --private-key file://privatekey.pem --certificate-chain file://certificate_chain_file

Unable to locate credentials. You can configure credentials by running "aws configure".

おお、使えない。

sudo yum install python-pip
sudo pip install awscli

Unable to locate credentials. You can configure credentials by running "aws configure". まだ使えない。AccessKeyとSecretKeyが必要で、それを設定する必要があるらしい。このKeyはIAMから取得できるらしい。IAMってなんだ。まあ、今いらないからいいや。

単純にアップして、httpd.conf(ssl.conf)を設定したら反映された。 chromeは、キャッシュしているらしく、正常に反映した後でも、URLバーが赤い状態になっていたが、ブラウザを再起動したら緑になった。