こんにちわ、ごきげんまるです。
今の世の中、SSL通信と言えばTLSが主流です。SSL3.0以前を使っている通信はほぼありません。以前よりSSL3.0以前は致命的な脆弱性を含んでいることから、利用が非推奨とされているからです。
ではTLSはどうかと言うと、TLSも1.1以前のバージョンは脆弱性を含んでおり、利用は非推奨となっております。
この辺の詳細については、IPAが出しているTLS暗号設定ガイドラインを読んでいただくのがいいのかなと思います。
http://ipa.go.jp/security/vuln/ssl_crypt_config.html
この流れは世界で進んでおり、AWSもTLS通信は1.2以上にするよう利用者に促しています。
APIGWのTLS設定箇所
カスタムドメインを設定している場合、TLSのバージョンがどの設定になっているか、ここで確認ができます。
この状態で接続をしてみると、TLS1.1以前のバージョンで接続すると拒否されることが分かります。
$ curl --tlsv1.0 https://example.com -vvv Note: Unnecessary use of -X or --request, GET is already inferred. * Trying xx.xx.xx.xx... * TCP_NODELAY set * Connected to example.com (xx.xx.xx.xx) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * TLSv1.0 (OUT), TLS header, Certificate Status (22): * TLSv1.0 (OUT), TLS handshake, Client hello (1): * TLSv1.0 (IN), TLS header, Unknown (21): * TLSv1.0 (IN), TLS alert, Server hello (2): * error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version * stopped the pause stream! * Closing connection 0 curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version $ $ $ curl --tlsv1.1 https://example.com -vvv Note: Unnecessary use of -X or --request, GET is already inferred. * Trying xx.xx.xx.xx... * TCP_NODELAY set * Connected to example.com (xx.xx.xx.xx) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * TLSv1.1 (OUT), TLS header, Certificate Status (22): * TLSv1.1 (OUT), TLS handshake, Client hello (1): * TLSv1.1 (IN), TLS header, Unknown (21): * TLSv1.1 (IN), TLS alert, Server hello (2): * error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version * stopped the pause stream! * Closing connection 0 curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
TLS1.2だとつながります。
$ curl --tlsv1.2 https://example.com -vvv Note: Unnecessary use of -X or --request, GET is already inferred. * Trying xx.xx.xx.xx... * TCP_NODELAY set * Connected to example.com (xx.xx.xx.xx) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Client hello (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=example.com * start date: May 13 00:00:00 2021 GMT * expire date: Jun 11 23:59:59 2022 GMT * subjectAltName: host "example.com" matched cert's "example.com" * issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon * SSL certificate verify ok. * Using HTTP2, server supports multi-use ~中略~ * Connection state changed (MAX_CONCURRENT_STREAMS updated)! < HTTP/2 403 ~中略~
APIGWのTLS設定を1.0に変更する
APIGWのTLSバージョンを1.0に変更してみます。
変更は以下で簡単にできます。
設定をすると、以下の通りTLSのバージョンが1.0に変わります。
これでTLS1.0、TLS1.1で接続すると、通信が通ることが確認できます。
$ curl --tlsv1.0 https://example.com -vvv Note: Unnecessary use of -X or --request, GET is already inferred. * Trying xx.xx.xx.xx... * TCP_NODELAY set * Connected to example.com (xx.xx.xx.xx) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.0 (OUT), TLS handshake, Client hello (1): * TLSv1.0 (IN), TLS handshake, Server hello (2): * TLSv1.0 (IN), TLS handshake, Certificate (11): * TLSv1.0 (IN), TLS handshake, Server key exchange (12): * TLSv1.0 (IN), TLS handshake, Server finished (14): * TLSv1.0 (OUT), TLS handshake, Client key exchange (16): * TLSv1.0 (OUT), TLS change cipher, Client hello (1): * TLSv1.0 (OUT), TLS handshake, Finished (20): * TLSv1.0 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.0 / ECDHE-RSA-AES128-SHA * ALPN, server accepted to use h2 * Server certificate: * subject: CN=example.com * start date: May 13 00:00:00 2021 GMT * expire date: Jun 11 23:59:59 2022 GMT * subjectAltName: host "example.com" matched cert's "example.com" * issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon * SSL certificate verify ok. * Using HTTP2, server supports multi-use ~中略~ * Connection state changed (MAX_CONCURRENT_STREAMS updated)! < HTTP/2 403 ~中略~