ä¸ç¹å®å¤æ°ã®ã¦ã§ããµã¤ãã«ã¢ã¯ã»ã¹ããã¢ããªã±ã¼ã·ã§ã³ãæ¸ãã¦ããã¨ãã¨ããã SSL 証ææ¸ã®æ¤è¨¼ã¨ã©ã¼ã¨ãªã URL ã«è¡ãå½ãããã¨ãããããã確èªã®ãããã©ã¦ã¶ã§ã¢ã¯ã»ã¹ãã¦ã¿ãã¨ãæ®éã«è¦ãã¦ãã¾ã£ãããããããããªäºä¾ã®ã²ã¨ã¤ãã¿ã¤ãã«ã®éãä¸éCA証ææ¸ã®ãªããµã¼ãã«ã¤ãã¦ã
https://incomplete-chain.badssl.com/ ã¨ããããããããä¾ããããããã curl ãã¦ã¿ãã¨:
% docker run -it --rm buildpack-deps:buster bash root@22f1788d53c7:/# curl --version curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 Release-Date: 2019-02-06 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL root@22f1788d53c7:/# curl -sS https://www.example.com/ > /dev/null # æ£å¸¸ç³»ã¨ã㦠root@22f1788d53c7:/# curl -sS https://incomplete-chain.badssl.com/ > /dev/null curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: https://curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
ã¨ãªãããã ãã©ãæå ã®ãã©ã¦ã¶ã§ã¯ãã¶ãã¨ãã«ã¨ã©ã¼ããªãéããï¼ã¯ãï¼ã
ãã® URL ã§ã¯ããµã¼ãã¯ããã¦ä¸é証ææ¸ãé ä¿¡ãã¦ããªããã«ãããããããã©ã¦ã¶ã§è¦ãã¦ãã¾ãã®ã¯ãbadssl.com ã®èª¬æã«ããã¨ã
- ãã©ã¦ã¶ãä¸é証ææ¸ããã£ãã·ã¥ãã¦ãã
- ã¾ãã¯ããã©ã¦ã¶ã AIA (= Authority Information Access) fetching ã«å¯¾å¿ãã¦ãã
ãããã¨ãããã¨ããããAIA 㯠SSL 証ææ¸ã®æ¡å¼µä»æ§ã§ããµã¼ãã®è¨¼ææ¸ã®çºè¡è ã®è¨¼ææ¸ã¸ã®ã¢ã¯ã»ã¹æ¹æ³ãè¨è¿°ããããã®ããã©ã¦ã¶ã§è¨¼ææ¸ã®æ å ±ãè¦ã¦ã¿ãã¨ç¢ºèªã§ããã¯ããè¦ã¦ã¿ãã¨è¨¼ææ¸ã® URL ã http: ã§è¨è¿°ããã¦ãããã¨ã«æåãã©ããããã©ãå¹³æã§åå¾ãã証ææ¸ãæ¤è¨¼ãããã®ã§ãå®å ¨æ§ã«ã¯åé¡ãªãã®ã ã£ãããããèªåçã«åå¾ãã¦ããã®ã AIA fetchingï¼ãªã®ã ã¨æãï¼ãAIA fetching ã¯æè¿ã®ã¡ã¸ã£ã¼ãªãã©ã¦ã¶ã 㨠Firefox 以å¤ã¯å¯¾å¿ãã¦ããã®ã ã¨ãã話ããã£ãããå ¬å¼ã«ã¢ãã¦ã³ã¹ãã¦ãããã®ã¯ããã«ã¯è¦ã¤ãããªãã£ããã½ã¼ã¹ãèªã¾ãªãã¨ãããªãã ããã
ä¸é証ææ¸ãã¾ã¨ãã¦åå¾ãã
ã§ããã©ã¦ã¶ã§è¦ããããã¼ã¸ã¯ã¢ããªã±ã¼ã·ã§ã³ãããåå¾ã§ããããã¨ããã®ã¯æ®éã«ããããéè¦ã§ããããã©ã®ããã«å®ç¾ããã®ããã¨ãã話ã
AIA fetching ãå®è£ ãã¦ãã¾ããã¨ããã®ãæ£æ»æ³ã§ã¯ãã£ã¦ãããããå®è£ ãããï¼æªæ¤è¨¼ï¼ã使ããã©ã¤ãã©ãªããªãå ´åãå®è£ ããããªãå ´åã«ããã¹ã¦ã®ãµã¤ããå°½ãããã¨ã¯ã§ããªããããããªããã©ãå¤ããã«ãã¼ã§ããæ¹æ³ã¨ãã¦ããããããä¸é証ææ¸ãæå ã«åå¾ãã¦ãããã¨ããæãããã§ã¯èããã
ã¤ã¾ããã«ã¼ãCA証ææ¸ã«ãã£ã¦ç½²åããã¦ããä¸é証ææ¸ãããããããã¦ã³ãã¼ããã¦ããã°ããããã ãããã¦ãé½åã®ãããã¨ã«ãããããªã¹ããä½ããã¦ããã
https://wiki.mozilla.org/CA/Intermediate_Certificates
Mozilla ã«ãã Common CA Database (CCADB) ããã¸ã§ã¯ã ã®ãªã½ã¼ã¹ã®ã²ã¨ã¤ã§ãMozilla ãä¿¡é ¼ãã¦ããã«ã¼ã CA ã«ãã£ã¦ç½²åãããä¸é証ææ¸ã®ä¸è¦§ãããããã®ãã¼ã¸ã®æ¨©å¨ã¯èªåã«ã¯ç¢ºèªã§ããªãã£ããã©ãã©ã®ã¿ã¡ãã§ã«ä¿¡é ¼ããã¦ããæå ã®ã«ã¼ã証ææ¸ã§æ¤è¨¼ããã®ã§ãããã£ã½ããã®ãç¶²ç¾ ããã¦ããã°åºèªã¯ãªãã§ãããã®ã§ããã
å è¿°ã®ãã¼ã¸ããä¸é証ææ¸ãåå¾ãããã§ã«æå ã«ããã«ã¼ã証ææ¸ã§æ¤è¨¼ã§ãããã®ã ãä¿åãããã¨ã«ãããDockerfile ã«ããã¨ããããæãã«ãªãã楽ãããã£ãã®ã§ãapt ã§å ¥ã csvtool ã¨ããã®ã使ã£ã¦ã¿ãã
FROM buildpack-deps:buster SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN apt-get update && \ apt-get install -y csvtool RUN mkdir -p /opt/intermediate-certs/certs && \ curl -sL https://ccadb-public.secure.force.com/mozilla/PublicAllIntermediateCertsWithPEMCSV | \ csvtool namedcol 'PEM Info' - | \ csvtool drop 1 - | \ # ããããè½ã¨ã csvtool call "printf '%q\n'" - | \ # æ¹è¡ãå«ã¾ãã¦ããã®ã§1è¡ã« while IFS= read -r e; do \ pem=$(eval "echo $e" | sed "s/'//"); \ # ' ãé¤ã if echo "$pem" | openssl verify; then \ # æ¢åã®ã«ã¼ã証ææ¸ã§æ¤è¨¼ echo "$pem" | \ tee -a /opt/intermediate-certs/ca-bundle.crt \ # 証ææ¸ãã³ãã«ãä½ã > /opt/intermediate-certs/certs/"$(echo "$pem" | openssl x509 -subject -noout | perl -pe 's/\W/_/g')".pem; \ # åå¥ã®è¨¼ææ¸ãä¿åãã fi; \ done && \ c_rehash /opt/intermediate-certs/certs
openssl verify
ãã¦æåãããã®ã ãä¿åãããä»æ°ã¥ãããã©ãä¸é証ææ¸ã«ãã£ã¦ç½²åããã¦ããä¸é証ææ¸ã¯ããã§è·³ãããã¦ãã¾ããªâ¦â¦ã
証ææ¸ãã³ãã«ã¯ãåã«ããã¹ãã¨ãã¦ä¸¦ã¹ã¦è¨è¿°ããã°ããï¼opensslãRFCï¼ãåãåããããããããã«ããã¹ã¦ã®è¨¼ææ¸ã1ãã¡ã¤ã«ã«ã¾ã¨ãããã®ã¨ããããå¥ã ã®ãã¡ã¤ã«ã«ãããã®ã¨ãä½ã£ã¦ããã
ä»ååå¾ããä¸é証ææ¸ãã·ã¹ãã ã«ãã®ã¾ã¾çµã¿è¾¼ãã§ãã¾ããããªããã·ã¹ãã ã®ã«ã¼ãï¼debian ãªã /etc/ssl/certs
ï¼ã«ç½®ãã¦ãã¾ãã°ããã®ã ãã©ãã¢ããªã±ã¼ã·ã§ã³å´ã§å¶å¾¡ããããã¨ãã»ã¨ãã©ã ã¨æãã®ã§ãå¥ã®å ´æã«ç½®ãã¦ããã®ã ããã ããã
ãã£ãã試ãã¦ã¿ãã--cacert
ããã¤ã³ãã--capath /opt/intermediate-certs/certs:/etc/ssl/certs
ã¨ãã¦ãããã
% docker run --rm -it $(docker build -q .) bash root@39401ca59f18:/# curl --version curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3 Release-Date: 2019-02-06 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL root@39401ca59f18:/# curl --cacert /opt/intermediate-certs/ca-bundle.crt -sS https://www.example.com/ > /dev/n ull root@39401ca59f18:/# curl --cacert /opt/intermediate-certs/ca-bundle.crt -sS https://incomplete-chain.badssl.com/ > /dev/null
ãã£ããï¼ æåã§ãã
ã¡ãªã¿ã«
ãã©ã¦ã¶ã®ç¢ºèªã ãã§æ¸ã¾ãã¦ãã¾ãã¨ãããããè¨å®æ¼ãã«æ°ã¥ãã«ããã¿ããã§ããMackerel ã®ãããªãµã¼ãã¹ã使ãã°ã証ææ¸ã®æéãªã©ãå«ãã¦ç£è¦ã§ãã¾ãããããã使ã£ã¦ãã¾ãï¼ ã©ãããå©ç¨ä¸ããã