{"id":9464,"date":"2020-09-10T02:27:32","date_gmt":"2020-09-09T17:27:32","guid":{"rendered":"http:\/\/hack.gpl.jp\/?p=5980"},"modified":"2020-09-10T02:27:32","modified_gmt":"2020-09-09T17:27:32","slug":"post-9464","status":"publish","type":"post","link":"https:\/\/hack.gpl.jp\/2020\/09\/10\/post-9464.html","title":{"rendered":"Termux\u3067\u306e\u30b9\u30de\u30db\u30b5\u30fc\u30d0\u3001SSL\u30a2\u30af\u30bb\u30b9\u3067\u3082\u8010\u3048\u308c\u305d\u3046\u304b\u306a\uff1f"},"content":{"rendered":"\n

Termux\u3067\u306eLet’s Encrypt\u3000SSL\u5316\u304c\u3084\u3063\u3068\u3067\u304d\u305f\u306e\u3067\u30e1\u30e2\u3063\u3066\u304a\u304d\u307e\u3059\uff01<\/p>\n\n\n\n

\u307e\u305a\u5fc3\u914d\u3060\u3063\u305f\u306e\u306f\u3001SSL\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3067\u3059\u304c\u3001\u307e\u3041\u6211\u6162\u3069\u3053\u308d\u3068\u3044\u3063\u305f\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

\u975eSSL\u3068\u6bd4\u3079\u308b\u3068\u3001\u63a5\u7d9a\u306b\u306f\u5c11\u3057\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u306b\u30b9\u30de\u30db\u304b\u3089SIM\u901a\u4fe1\u3057\u3066\u307f\u308b\u3068\u3001\u82e5\u5e72\u30ef\u30f3\u30c6\u30f3\u30dd\u9001\u308c\u308b\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n

\u8a3c\u660e\u66f8\u306f\u3001Let’s Encrypt \u3067\u3053\u308c\u306f\uff13\u30f6\u6708\u3054\u3068\u306b\u66f4\u65b0\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u81ea\u52d5\u5316\u304c\u5fc5\u9808\u3068\u306a\u3063\u3066\u304d\u307e\u3059\u3002\u624b\u52d5\u3067\u3084\u3063\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u7d76\u5bfe\u9762\u5012\u306b\u306a\u3063\u3066\u8a3c\u660e\u66f8\u3092\u5207\u3089\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3002\u3067\u3001\u81ea\u52d5\u5316\u306b\u306f certbot<\/a> \u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u6709\u540d\u306a\u3093\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u4f9d\u5b58\u95a2\u4fc2\u306a\u3069\u304c\u3042\u3063\u305f\u308a\u3001root \uff08\u30b9\u30af\u30ea\u30d7\u30c8\u4e2d\u3067 su \u3057\u305f\u308a\uff09\u304c\u5fc5\u9808\u3068\u304b\u3067\u3001Termux \u3067\u306f\u52d5\u304d\u307e\u305b\u3093\u3002\u52d5\u304b\u3059\u65b9\u6cd5\u3082\u3042\u308b\u306e\u3067\u3057\u3087\u3046\u304c\u3001\u4e16\u306e\u4e2d\u306b\u306f\u3082\u3063\u3068\u5c0f\u3055\u306a\u81ea\u52d5\u5316\u30c4\u30fc\u30eb\u304c\u3042\u308a\u307e\u3057\u305f\uff01<\/p>\n\n\n\n

acme-tiny<\/a> \u3063\u3066\u3044\u3046Python\u88fd\u306e\u81ea\u52d5\u5316PG\u3067\u3059\u3002python\u3068openssl \u304c\u3042\u308c\u3070\u52d5\u304f\u305d\u3046\u3067\u3059\u3002pip \u3067\u5165\u308c\u3066\u898b\u307e\u3059\u3002<\/p>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff11 python\u3092\u5165\u308c\u308b<\/h3>\n\n\n\n

python\u304c\u5fc5\u8981\u306a\u306e\u3067\u3001\u306a\u3051\u308c\u3070\u5165\u308c\u307e\u3059\u3002\u4eca\u56de\u306f\u3001\u3082\u3046\u5165\u308c\u3066\u3042\u308b\u306e\u3067\u6b21\u3067\u3059\u3002<\/p>\n\n\n\n

$ dpkg-query -l | grep python\nii  python             3.8.5             aarch64      Python 3 programming language intended to enable clear programs\n\n$ pkg install python -y<\/code><\/pre>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff12\u3000PIP\u3067 acme-tiny \u3092\u5165\u308c\u308b<\/h3>\n\n\n\n
$ pip install acme-tiny<\/code><\/pre>\n\n\n\n

pip \u304c\u53e4\u3044\u3068\u304b\u8a00\u308f\u308c\u305f\u3089\u3001\u4ee5\u4e0b\u3067\u3002<\/p>\n\n\n\n

$ python3 -m pip install --upgrade pip<\/code><\/pre>\n\n\n\n

\u4ee5\u4e0b\u306b\u5165\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n

$ which acme-tiny\n\/data\/data\/com.termux\/files\/usr\/bin\/acme-tiny\n\n$ find $PREFIX -name *acme*\n\/data\/data\/com.termux\/files\/usr\/bin\/acme-tiny\n\/data\/data\/com.termux\/files\/usr\/lib\/python3.8\/site-packages\/acme_tiny.py\n\/data\/data\/com.termux\/files\/usr\/lib\/python3.8\/site-packages\/__pycache__\/acme_tiny.cpython-38.pyc\n\/data\/data\/com.termux\/files\/usr\/lib\/python3.8\/site-packages\/acme_tiny-4.1.0.dist-info<\/code><\/pre>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff13\u3000Let’s Encrypt\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u79d8\u5bc6\u9375<\/h3>\n\n\n\n

\u3069\u3053\u304b\u9069\u5f53\u306a\u5834\u6240\u306b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u3063\u3066\u3001\u305d\u3053\u3067\u4f5c\u696d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

$ cd\n$ mkdir ssl\n$ cd ssl\n$ openssl genrsa 4096 > account.key<\/code><\/pre>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff14\u3000\u30c9\u30e1\u30a4\u30f3\u7528\u306e\u79d8\u5bc6\u9375\u3092\u4f5c\u6210<\/h3>\n\n\n\n

\u30c9\u30e1\u30a4\u30f3\u540d\u306f\u3001\u8aad\u307f\u66ff\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n

$ openssl genrsa 4096 > www.example.jp.key<\/code><\/pre>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff15\u3000\u30c9\u30e1\u30a4\u30f3\u306e\u8a3c\u660e\u66f8\u7f72\u540d\u8981\u6c42\uff08CSR\uff09\u3092\u4f5c\u6210<\/h3>\n\n\n\n
\u30b7\u30f3\u30b0\u30eb\u30c9\u30e1\u30a4\u30f3\n$ openssl req -new -sha256 -key www.example.jp.key -subj \"\/CN=www.example.jp\" > www.example.jp.csr<\/code><\/pre>\n\n\n\n

\u30b5\u30d6\u30c9\u30e1\u30a4\u30f3\u306e\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u8a3c\u660e\u66f8\u306f\u3069\u3046\u3084\u3063\u3066\u4f5c\u308b\u306e\u304b\u307e\u3060\u77e5\u308a\u307e\u305b\u3093\u3002\u8ab2\u984c\u3067\u3059\u3002<\/p>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff16\u3000\u8a3c\u660e\u66f8\u306b\u7f72\u540d\u3057\u3066\u3082\u3089\u3046<\/h3>\n\n\n\n
$ mkdir -p \/data\/data\/com.termux\/files\/home\/\u3010WEBROOT\u3011\/.well-known\/acme-challenge\/\n\n$ acme-tiny --disable-check --account-key .\/account.key --csr .\/www.example.jp.csr --acme-dir \/data\/data\/com.termux\/files\/home\/\u3010WEBROOT\u3011\/.well-known\/acme-challenge\/ > .\/www.example.jp.crt<\/code><\/pre>\n\n\n\n

\u3053\u3053\u3067\u3001–disable-check\u3000\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u304c\u3053\u308c\u306f\u5148\u65e5\u8a18\u8f09\u3057\u305fU\u30bf\u30fc\u30f3NAT\uff08\u30d8\u30a2\u30d4\u30f3NAT\uff09\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u81ea\u5206\u81ea\u8eab\u306eWEB\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044\u304b\u3089\u3067\u3059\u3002\u305d\u3046\u3044\u3046\u554f\u984c\u304c\u306a\u3044\u5834\u5408\u306f\u3001\u524a\u9664\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n

\u3053\u3093\u306a\u611f\u3058\u3067\u51fa\u6765\u308b\u3068\u601d\u3044\u307e\u3059\u3002crt\u304c\u3067\u304d\u306a\u3044\u5834\u5408\u306f\u4f55\u304b\u304c\u60aa\u3044\u3067\u3059\u3002\u30ed\u30b0\u306b\u30d2\u30f3\u30c8\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u614c\u3066\u305a\u3001\u63a2\u308a\u307e\u3057\u3087\u3046\uff01<\/p>\n\n\n\n

.\n\u251c\u2500\u2500 account.key\n\u251c\u2500\u2500 www.example.jp.crt\u3000\u7f72\u540d\u3055\u308c\u305f\u8a3c\u660e\u66f8\n\u251c\u2500\u2500 www.example.jp.csr\n\u2514\u2500\u2500  www.example.jp.key\u3000\u9375\n\n.WEBROOT\n    \u2514\u2500\u2500 .well-known\n        \u2514\u2500\u2500 acme-challenge\n           \u2514\u2500\u2500xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<\/code><\/pre>\n\n\n\n

\u30b9\u30c6\u30c3\u30d7\uff17\u3000nginx\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n

\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u629c\u7c8b\u3002\u30eb\u30fc\u30bf\u3068termux\u306f\u30dd\u30fc\u30c8\u8ee2\u9001\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n

http {\n\uff1a\uff1a\uff08\u7565\uff09\n    ssl_session_timeout 30m;\n    ssl_session_cache   shared:SSL:10m;\n    ssl_session_tickets off;\n    ssl_protocols TLSv1.2 TLSv1.3;\n    ssl_prefer_server_ciphers on;\n    ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256;\n\uff1a\uff1a\uff08\u7565\uff09\nserver {\n     listen      8443;\n\uff1a\uff1a\uff08\u7565\uff09\n     ssl_certificate     \/data\/data\/com.termux\/files\/home\/ssl\/www.example.jp.crt;\n     ssl_certificate_key \/data\/data\/com.termux\/files\/home\/ssl\/www.example.jp.key;\n\uff1a\uff1a\uff08\u7565\uff09\n<\/code><\/pre>\n\n\n\n

\u306a\u305c\u304b\u3001location \u3067\u3001.well-known\/acme-challenge\/\u3000\u306e\u5834\u6240\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u305f\u3089\u3001\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u306a\u306e\u3067\u3001\u3053\u308c\u306f\u6d88\u3057\u3066\u3001\u5b9f\u969b\u306eWEBROOT\u306b\/.well-known\/acme-challenge\/\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

location ^~ \/.well-known\/acme-challenge\/ {\n    root \/data\/data\/com.termux\/files\/home\/\u3010acme-challenge\u304c\u3042\u308b\u30d1\u30b9\u3011;\n}\nlocation = \/.well-known\/acme-challenge\/ {\n    return 404;\n}<\/code><\/pre>\n\n\n\n

\u4ee5\u4e0b\u306e\u8a55\u4fa1\u304c\u5148\u306b\u30de\u30c3\u30c1\u3057\u3066\u3057\u307e\u3063\u3066\u3001\u3053\u308c\u3082\u4e00\u6642\u7684\u306b\u6d88\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n

location ~ \/\\. {\n    return 404;\n}<\/code><\/pre>\n\n\n\n

nginx\u306e\u8a2d\u5b9a\u3001\u4e0d\u6163\u308c\u306a\u3093\u3067\u3069\u3053\u304b\u304a\u304b\u3057\u3044\u3093\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n\n\n\n

\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u8a3c\u660e\u66f8\u304c\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3089\u3001cron\u306b\u5b9a\u671f\u5b9f\u884c\u3057\u3066\u3082\u3089\u304a\u3046\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3082\u3046\u5c11\u3057\u3044\u308d\u3044\u308d\u8a66\u3057\u3066\u307f\u3066\u304b\u3089\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n

SSL\u306e\u30c1\u30a7\u30c3\u30af\u3082\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

PageSpeed Insights\u306e\u30e2\u30d0\u30a4\u30eb\u306e\u30b9\u30b3\u30a2\u3082\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

PC\u7248\u306f\uff11\uff10\uff10\u70b9\u51fa\u307e\u3057\u305f\uff01<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

\u3068\u3044\u3046\u3053\u3068\u3067\u3001Termux \u306enginx\u3068php-fpm\u3067\u7121\u6599\u306e\u8a3c\u660e\u66f8\u3092\u5165\u308c\u3066\u901f\u5ea6\u7684\u306b\u3082\u554f\u984c\u306a\u3055\u305d\u3046\u304b\u306a\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n

\u3042\u3068\u306f\u3001\u4eca\u56de\u51fa\u305f\u3082\u308d\u3082\u308d\u306e\u554f\u984c\u3092\u30af\u30ea\u30a2\u306b\u3057\u3066\u30de\u30af\u30ed\u3092\u5b9a\u671f\u5b9f\u884c\u3067\u304d\u308c\u3070OK\u3067\u3059\u3002\u307c\u3061\u307c\u3061\u3084\u3063\u3066\u3044\u304d\u307e\u3059\u3002\u3067\u3082\u300110\u6708\u306f\u3058\u3081\u307e\u3067\u306b\u306f\u3001\u79fb\u884c\u5b8c\u4e86\u3057\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093\u306e\u3067\u3001\u305d\u308c\u307e\u3067\u306b\u306fCDN\u554f\u984c\u3082\u30af\u30ea\u30a2\u3057\u3066\u8a66\u3057\u3066\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n\n\n\n

\u826f\u304f\u308f\u304b\u3089\u3093\u3053\u3068\uff01<\/h3>\n\n\n\n

\u30fbnginx\u306elocation\u306e\u30de\u30c3\u30c1\u306f\u3069\u3046\u306a\u3063\u3066\u308b\u306e\u304b\uff1f<\/p>\n\n\n\n

\u30fb\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\u8a3c\u660e\u66f8\u306f\u3069\u3046\u3084\u3063\u3066\u4f5c\u308b\u306e\u304b\uff1fCSR\u306e\u4f5c\u308a\u65b9\u3063\u307d\u3044\u304c\uff1f<\/p>\n\n\n\n

\u30fb\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u30fc\u3067SSL\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"

Termux\u3067\u306eLet’s Encrypt\u3000SSL\u5316\u304c\u3084\u3063\u3068\u3067\u304d\u305f\u306e\u3067\u30e1\u30e2\u3063\u3066\u304a\u304d\u307e\u3059\uff01 \u307e\u305a\u5fc3\u914d\u3060\u3063\u305f\u306e\u306f\u3001SSL\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u3067\u3059\u304c\u3001\u307e\u3041\u6211\u6162\u3069\u3053\u308d\u3068\u3044\u3063\u305f\u611f\u3058\u3067\u3057\u3087\u3046\u304b\u3002 \u975eSSL\u3068\u6bd4\u3079\u308b […]<\/p>\n","protected":false},"author":1,"featured_media":9497,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","footnotes":""},"categories":[47,83,32],"tags":[],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false],"thumbnail":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",96,96,false],"medium":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false],"medium_large":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl-768x768.png",768,768,true],"large":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false],"1536x1536":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false],"2048x2048":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false],"post-thumbnail":["https:\/\/hack.gpl.jp\/wp-content\/uploads\/2020\/09\/termuxssl.png",800,800,false]},"uagb_author_info":{"display_name":"JunkHack","author_link":"https:\/\/hack.gpl.jp\/author\/junkhack\/"},"uagb_comment_info":0,"uagb_excerpt":"Termux\u3067\u306eLet’s Encrypt\u3000SSL\u5316\u304c\u3084\u3063\u3068\u3067\u304d\u305f\u306e\u3067\u30e1\u30e2\u3063\u3066\u304a\u304d\u307e\u3059\uff01 \u307e\u305a\u5fc3\u914d…","_links":{"self":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/9464"}],"collection":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/comments?post=9464"}],"version-history":[{"count":0,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/9464\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/media\/9497"}],"wp:attachment":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/media?parent=9464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/categories?post=9464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/tags?post=9464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}