GAE å ¬å¼ã§ Let's encrypt ã«å¯¾å¿!
2017å¹´9æãããGAEèªä½ãLet's encrypt ã«å¯¾å¿ãã¾ããã ããã«ãããã³ã³ã½ã¼ã«ããã®ç°¡åæä½ã§SSL証ææ¸ãå°å ¥ã§ããããã«ãªãã¾ããã ããã Google ãèªåçã«è¨¼ææ¸ãæ´æ°ãã¦ããã¾ãã ä»ããè¨å®ãã人ã¯ããã¡ãã使ãã¾ãããã
ç¡æã§SSL/TLS証ææ¸ãçºè¡ã§ããLets' Encryptããã¸ã§ã¯ããã2016å¹´4æãã¤ãã«ãã¼ã¿çããæ£å¼çã«ãªãã¾ããã
ç¡æã¨ãã£ã¦ããMozillaãGoogle, Facebookãªã©ã®ã¦ã§ãä¼æ¥ããã·ã¹ã³ãã¢ã«ãã¤ãªã©ã®ãããã¯ã¼ã¯é¢ä¿ã®å¤§å¾¡æãæ¯æ´ãã¦ããããã¸ã§ã¯ããªã®ã§ã審æ»ããªãå ¨èªåã§çºè¡ãããã¿ã¤ãã®1,000-2,000åãããã®ææã®SSL証ææ¸ã¨å ¨ãéè²ããã¾ãã*1ã
æ¥ççã«ã¦ã§ãã®æå·åã«åãã¦ãã®ãããªããã¸ã§ã¯ããåããã¦ããã®ã¯ç´ æ´ãããã§ããã
GAEã¸ã®SSL/TLS証ææ¸ã®å°å ¥
ãã¦ãç¬èªãã¡ã¤ã³éç¨ããã¦ããGoogle App Engine(GAE)ã®ãµã¤ããSSL/TLS対å¿ããã¦ã¿ã¾ãããã
Let's Encrypt ã§ã¯ã証ææ¸çºè¡ã®éã«ããã¡ã¤ã³ã®ææã®ç¢ºèªã®ãããæå®ãããURLã«ãã¡ã¤ã«ãã¢ãããã¼ãããå¿ è¦ãããã¾ããããããããã»ã¹ã§ããã
é常ã®ãµã¼ãã¼ã®å ´åã¯ããã®ç¢ºèªç¨ã®ãã¡ã¤ã«ã®è¨å®ããApache/nginxãªã©ã®è¨å®ãcertbotã¨ããããã°ã©ã ã証ææ¸ã®åå¾ã¨ãããã¦ãã£ã¦ãããã®ã§ãããGAEã®å ´å証ææ¸ã®è¨å®ã¯GUIã§ããã§ãã¾ããã
ããã§ã証ææ¸ã®åå¾ã®ã¿è¡ãmanual
ã¢ã¼ãã§è¡ãã¾ãããªã®ã§ãã®ããã«ãããããµã¼ãã¼ãç«ã¦ãå¿
è¦ã¯ããã¾ããã以ä¸ã§ã¯ Mac OSX 10.11.4ã§ä½æ¥ãã¾ããã
1. ç¬èªãã¡ã¤ã³ã®è¨å®ãçµãã¦ãã
ã¾ãã¯ãç¬èªãã¡ã¤ã³ãGAEã§è¡¨ç¤ºã§ããç¶æ ã«ãã¦ããã¾ãã ãã¨ã®ã¹ãããã§ãLet's Encrypt ããåå¾ãããã¨ãã証ææ¸ç¨ã®ãµã¼ãã¼ã«ãªã¯ã¨ã¹ããæ¥ã¦ææã®ç¢ºèªãè¡ãããã®ã§ãDNSã®è¨å®ãªã©ã¯æ¸ã¾ãã¦ããå¿ è¦ãããã¾ãã
2. 証ææ¸ã®åå¾
ã¾ãã¯ãLet's Encrypt ã®ã¯ã©ã¤ã¢ã³ãã®ã¤ã³ã¹ãã¼ã«ãè¡ãã¾ãã
cloneãã¾ãã10MBã»ã©ããã®ã§ãããããæéãããã¾ãã
$ git clone https://github.com/certbot/certbot $ cd certbot
ããã§ã¯æ©é証ææ¸ãåå¾ãã¦ã¿ã¾ããããååã¯å¿ è¦ãªããã°ã©ã ã®ã¤ã³ã¹ãã¼ã«ãè¡ãããã®ã§ãæéããããã¾ãã ã¾ãç°å¢ã®rootã®PWãæ±ããããå ´åãããã¾ãã
ååã®ã¿ãã¡ã¼ã«ã¢ãã¬ã¹ãèãããã®ã¨ãå©ç¨è¦ç´ã¸ã®åæãæ±ãããã¾ãã
ã¡ãªã¿ã«ãã®cert-only
ã®onlyã¨ããã®ã¯ãã¤ã³ã¹ãã¼ã«ãè¡ãrun
ã«å¯¾ãã¦ãã¤ã³ã¹ãã¼ã«ã¯ããªããã¨ããæå³ã§ãã
ã¾ã以åã¯ãletsencrypt-auto
ã§ãããã2016å¹´5æããcertbot-auto
ã«å¤æ´ã«ãªã£ãããã§ãã
$ ./certbot-auto certonly --manual # PWãæ±ãããããã
å¿ è¦ãªããã«ã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«ãçµããã¨ã次ã®ãããªç»é¢ã«ãªãã¾ãã ããã«åå¾äºå®ã®ãã¡ã¤ã³ãå ¥åãã¾ããã«ã³ãåºåãã¹ãã¼ã¹åºåãã§è¤æ°å¯ã
次ã«ã¯ã©ã¤ã¢ã³ãã®IPã¢ãã¬ã¹ããã°ã«è¨é²ããå ¬éããããã¨ã«å¯¾ããåæ確èªç»é¢ãYesã§é²ã¿ã¾ãã
次ã«ä»¥ä¸ã®ãããªã¡ãã»ã¼ã¸ã表示ããã¾ãã
Make sure your web server displays the following content at http://cheetahapp.net/.well-known/acme-challenge/gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck before continuing: gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck.5Hvrmt1oBopQ03IDSAdTZRRoXZACheMnLi_Y272bLx4 If you don't have HTTP server configured, you can run the following command on the target server (as root): mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge cd /tmp/certbot/public_html printf "%s" gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck.5Hvrmt1oBopQ03IDSAdTZRRoXZACheMnLi_Y272bLx4 > .well-known/acme-challenge/gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck # run only once per server: $(command -v python2 || command -v python2.7 || command -v python2.6) -c \ "import BaseHTTPServer, SimpleHTTPServer; \ s = BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandler); \ s.serve_forever()" Press ENTER to continue
ããã¯ã¯ããæ°æã¡ãæãã¦ã¾ã ENTERã¯æ¼ãã¾ããï¼ï¼
æ示ã©ããã«ãLet's Encryptããã®ã¡ãã»ã¼ã¸ã®åå¨ç¢ºèªç¨URLã«ããã¹ããç½®ãã¾ãã ä¸è¨ã®å ´åã¯ã以ä¸ã®URLã§ä»¥ä¸ã表示ãããããã«ãã¾ãã
URL: http://cheetahapp.net/.well-known/acme-challenge/gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck
å 容: gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck.5Hvrmt1oBopQ03IDSAdTZRRoXZACheMnLi_Y272bLx4
GAEã§ã¯ä»¥ä¸ã®æ§ã«è¨å®ãã¾ãã
lets_encrypt.txt
:
gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck.5Hvrmt1oBopQ03IDSAdTZRRoXZACheMnLi_Y272bLx4
app.yaml
:
- url: /.well-known/acme-challenge/gTIjcnRpydLV5lcRDD-b-2TcTRh4YyZC26jDSZOx2ck static_files: lets_encrypt.txt upload: lets_encrypt.txt
ãããã¤ãã¾ãã
$ appcfg update .
ãã£ãã®URLãã¯ãªãã¯ãã¦å 容ã表示ããããã¨ã確èªããããã¨ã³ã¿ã¼ãæ¼ãã¾ãã
ãã°ããããã¨ã以ä¸ã®ãããªå 容ã表示ããã¦ç¡äºè¨¼ææ¸ãåå¾ã§ãã¾ããã
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/cheetahapp.net/fullchain.pem. Your cert will expire on 2016-08-31. To obtain a new or tweaked version of this certificate in the future, simply run certbot-auto again. To non-interactively renew *all* of your ceriticates, run "certbot-auto renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
証ææ¸ã¨ç§å¯éµã¯/etc/letsencrypt/live/[domain_name]
ã«ããã¾ãã
$ sudo ls /etc/letsencrypt/live/cheetahapp.net cert.pem chain.pem fullchain.pem privkey.pem
ç§å¯éµã復å·åãã¾ãã
$ sudo openssl rsa -in /etc/letsencrypt/live/[domain_name]/privkey.pem -out /etc/letsencrypt/live/[domain_name]/privkey_no_pass.pem
3. GAEã¸ã®ç»é²
GCPã®ã³ã³ã½ã¼ã«ãããGAEâè¨å®âSSL 証ææ¸âæ°ãã証ææ¸ãã¢ãããã¼ãã®é ã«éãã¾ãã
ãPEM ã§ã¨ã³ã³ã¼ãããã X.509 å
¬ééµè¨¼ææ¸ãã®æ¬ã«ãfullchain.pem
ãã
ã復å·åããã PEM ã§ã¨ã³ã³ã¼ãããã RSA ç§å¯éµãã®æ¬ã«privkey_no_pass.pem
ããã¼ã¹ããã¾ãã
ããã§å¾©å·åãå¿ããã¨é¸æããç§å¯éµã¯æå¹ã§ã¯ãªãããã§ãã
ã¨ããã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示ããã¾ããããçµæ§ã¯ã¾ãã¾ããï½
4. åä½ç¢ºèª
ç¡äºã«è¨å®ã§ããã¨ã以ä¸ã®ããã«ã¢ãã¬ã¹ãã¼ãç·ã«ãªãã¾ãããã£ãï¼ï¼
èª²é¡ è¨¼ææ¸ã3ã¶æã§åãã¦ãã¾ã
SSL証ææ¸ã¯3ã¶æã§åãã¦ãã¾ãã¾ããé常年åä½ã§ã®æ´æ°ãªã®ã§ããã¯ã¡ãã£ã¨é¢åã§ãã
ãµã¼ãã¼èªä½ã«certbotãå
¥ããã°ã/etc/letsencrypt/live/[domain_name]
ã«å¸¸ã«ææ°ã«è¨¼ææ¸ã®ã·ã³ããªãã¯ãªã³ã¯ãè²¼ãããã®ã§æéã¯ãªãã®ã§ãããGAEã ã¨ããã¯ããã¾ããã
証ææ¸ã®ååå¾ã¯ã³ãã³ãã§ããã®ã§ãããGAEã¸ã®è¨¼ææ¸ã®éä¿¡ã¯APIãªã©ããã®ã§ããããã軽ãæ¢ããã¨ããã¯è¦ã¤ããã¾ããã§ããã
3ã¶æããã«ãã©ã¼ã è¡ãã®ã¯å°å³ã«é¢åãªã®ã§ãããã«1000åæãã¨å²ããã£ã¦æ¢åã®SSLæ¥è ã使ããã¨ããã®ãããããããã¾ããã
証ææ¸ã®æ´æ° (2016/11/1 追è¨)
æ©é3ãæçµã£ãã®ã§ã証ææ¸ã®æ´æ°ãè¡ãã¾ããã æ´æ°ã§ããã¡ã¤ã«ãã¢ãããã¼ãããå¿ è¦ãããã¾ãããã¢ãããã¼ãããURLã¨ãã¡ã¤ã«å 容ã¯åããªã®ã§ãã³ãã³ãæ¼ãã¦ããã°ç°¡åã«æ°ãã証ææ¸ãåå¾ã§ãã¾ãã ã³ãã³ãããã¡ã¢ã£ã¦ããã°5åãããã°æ´æ°å®äºããã®ã§ããããªã«æéã§ãããã¾ãããã
ãã ã¾ãGAEã¨ãã«é¢ãã¦ã¯ãã®ä½æ¥å®å ¨èªååãã¦ããããå¬ãããã§ããã©ãã¼ãã
ã¾ã¨ã
GAEã®SSL対å¿ããããããã°5åãããã§çµãã£ã¦ãã¾ãã¾ããã ãã¤ãSSL対å¿ã¯ãç§å¯éµä½ã£ã¦ããã§CSRä½ã£ã¦ä¼ç¤¾ã®ãµã¤ãã®ãã©ã¼ã ã«è¡ã£ã¦çºè¡ä¾é ¼ãã¦ãã¡ã¼ã«ã¯ãªãã¯ãã¦ã証ææ¸DLãã¦ãªã©è¤éãªæé ã ã£ãã®ã§ãããªãç°¡åã«ãªãã¾ããã ãããå ¨é¨ç¡æãæä¾ãã¦ããã®ãã·ã¹ã³ã»ã¢ã«ãã¤ãGoogleãFacebookãªã®ã§å²ã¨å®å¿ãã¨ãããã¨ã§ãéè¡ãªã©ã使ã£ã¦ããã¢ãã¬ã¹ãã¼ã«ç·ã®çµç¹åã表示ãããEV SSL以å¤ã¯ã©ãã©ã移è¡ãé²ãããããªãã§ããããã
åè
qiita.com ç§å¯éµã®å¾©å·åã§åãã¯ã¾ããããã¦ããæ¹ï½
qiita.com åæ§ã®ãã¨ãGCEã®ã¤ã³ã¹ã¿ã³ã¹ã§è¡ã£ãäºä¾ã
*1:ã©ã¡ããæ¹ããã¨çè´ã«ã¯å¹æãããã¾ããããªããã¾ãã«ã¯ç¡åã§ãã