3ヶ月前に okamuuu.com を作った時についでに https に対応させたんですが、忘れた頃に更新しないといけないので備忘録
手元の MacOSX 上で最初にデプロイできるか確認
とりあえず自分のアプリがデプロイできるかどうかを確認します。
この3ヶ月でマシンを新調していたので gcloud コマンドがはいってなかった...
which gcloud
gcloud not found
ここからダウンロードする。
https://cloud.google.com/sdk/docs/quickstart-mac-os-x
そのあと ./install.sh
を実行して SHELL を再起動します。
事前にデプロイの手順を確認する理由は証明書を作成する手順を実行している最中に指定されたファイルを GAE にアップする必要があるためです。
Google clouls shell で GAE 上で証明書を作成します。
let's encrypt を準備します。すでに letsencrypt
ディレクトリができていたら前回すでに実行しているので git pull
しておきましょう。
git clone https://github.com/letsencrypt/letsencrypt && cd letsencrypt
証明書を作成します。モジュールが入っていない場合は結構時間がかかります。
cd ~/letsencrypt
sudo ./letsencrypt-auto -a manual certonly
以下ダイアログ。
- Emailアドレスを入力
- 規約に同意
- Electronic Frontier Foundation にアドレスを Share するかに答える
- 該当するドメインを指定
- IP を記録する事に同意
Enter email address (used for urgent renewal and security notices) If you
really want to skip this, you can run the client with
--register-unsafely-without-email but make sure you then backup your account key
from /etc/letsencrypt/accounts (Enter 'c' to cancel):okamuuu@gmail.com
-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A
-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c'
to cancel):okamuuu.com
Are you OK with your IP being logged?
-------------------------------------------------------------------------------
(Y)es/(N)o: Y
そうすると下記ようのようなチャレンジコードが画面に表示されます。
Make sure your web server displays the following content at
http://okamuuu.com/.well-known/acme-challenge/123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx before continuing:
123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
これは http://okamuuu.com/.well-known/acme-challenge/123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
に Request したら 123456789xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
を返すようにしてね。という事を言っています。
この画面を表示させたまま(Enter をまだ押さない)状態で GAE に Static file をアップします。その後 Enter を押します。
その後に Cloud Shell の次のコマンドで公開鍵証明書の中身を取得しておきます。
sudo less /etc/letsencrypt/live/okamuuu.com/fullchain.pem
次に秘密鍵
sudo openssl rsa -inform pem -in /etc/letsencrypt/live/okamuuu.com/privkey.pem -outform pem | less
上記の2つの鍵を Google Console 上で SSL 証明書として登録すれば作業完了
参考
http://blog1.erp2py.com/2016/06/gaessllets-encrypt.html