gokigenmaruのブログ

40から始めるクラウドエンジニア

APIGWでTLS1.1以前の通信がブロックされる

こんにちわ、ごきげんまるです。

今の世の中、SSL通信と言えばTLSが主流です。SSL3.0以前を使っている通信はほぼありません。以前よりSSL3.0以前は致命的な脆弱性を含んでいることから、利用が非推奨とされているからです。
ではTLSはどうかと言うと、TLSも1.1以前のバージョンは脆弱性を含んでおり、利用は非推奨となっております。
この辺の詳細については、IPAが出しているTLS暗号設定ガイドラインを読んでいただくのがいいのかなと思います。
http://ipa.go.jp/security/vuln/ssl_crypt_config.html

この流れは世界で進んでおり、AWSTLS通信は1.2以上にするよう利用者に促しています。

APIGWのTLS通信バージョン

APIGWのTLS通信はデフォルトで1.2以上となります。
数年前はデフォルトはTLS1.0以上でしたが、上記の流れもあり、デフォルトで1.2以上となっています。

ですが、カスタムドメインの設定をしている場合はTLSの接続バージョンを1.0以上に設定することができます。

APIGWのTLS設定箇所

カスタムドメインを設定している場合、TLSのバージョンがどの設定になっているか、ここで確認ができます。

f:id:gokigenmaru:20210528093429p:plain
APIGWTLS(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に変更してみます。
変更は以下で簡単にできます。

f:id:gokigenmaru:20210528095018p:plain
APIGWTLS(TLS設定1)
f:id:gokigenmaru:20210528095046p:plain
APIGWTLS(TLS設定2)

設定をすると、以下の通りTLSのバージョンが1.0に変わります。

f:id:gokigenmaru:20210528095358p:plain
APIGWTLS(TLSバージョン確認2)

これで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
~中略~

まとめ

AWSのAPIGWのカスタムドメインではデフォルトでTLS1.2以上が設定されているが、TLS1.0以前の通信がある場合はTLS1.0(TLS1.1含む)に変更することが出来る。
ただし、現在はTLS1.1以前に脆弱性があり、TLS1.1以前を使わないことが推奨されていることからセキュリティのリスクを受け入れたうえでの設定・運用が必要。