11
9

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.

AWSへ証明書アップロード

Last updated at Posted at 2016-04-07

#前置き

S3で独自ドメインをSSLに対応させるにはCloudFrontを使う必要がある

ELBやCloudFrontへSSL証明書を登録などの作業は
ManegemntConsoleでは不可能でAWS-CLIを使用する必要がある
MacOSではTeminalでそのまま作業ができる
(バージニアだとACM使えるけどACM発行じゃないとだめ?)

#AWS-CLIのインストール

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
pip install awscli

#IAMユーザの作成
今使ってるIAMユーザを使うか専用のユーザを作成
アクセスキーを確保しておく

#証明書作業用のポリシーを作成
カスタムポリシーを以下のように作成し、ユーザにアタッチする

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:DeleteServerCertificate",
                "iam:UploadServerCertificate",
                "iam:UpdateServerCertificate",
                "iam:ListServerCertificates",
                "iam:GetServerCertificate"
            ],
            "Resource": "*"
        }
    ]
}

#AWS-CLIの設定

$ aws configure
AWS Access Key ID [None]:アクセスキー
AWS Secret Access Key [None]:シークレットキー
Default region name [None]:ap-northeast-1
Default output format [None]:

#SSL証明書の導入
##秘密鍵のチェック
$ openssl rsa -in test.key -check -noout
RSA key ok
##証明書の動作チェック

$ openssl s_server -accept 10443 -cert test.crt -key test.key -CAfile test中間証明.crt -WWW

ACCEPT

#SSL証明書をAWSにアップ

$ aws iam upload-server-certificate --server-certificate-name .com --certificate-body file://test.crt --private-key file://test.key --certificate-chain file://test中間証明書.crt --path /cloudfront/hogehoge.com/
{
    "ServerCertificateMetadata": {
        "ServerCertificateId": "xxxxxxxxxxxxxxxxxx",
        "ServerCertificateName": "hogehoge.com",
        "Expiration": "2016-07-15T16:16:20Z",
        "Path": "/cloudfront/hogehoge.com/",
        "Arn": "arn:aws:iam::1234567890:server-certificate/cloudfront/hogehoge.com/hogehoge.com",
        "UploadDate": "2016-04-06T08:48:03.087Z"
    }
}

上記表示で完了
これでManegementConsole上で設定できる

11
9
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
11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?