本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
驗證 Amazon ECS Service Connect 是否啟用 TLS
Service Connect 會在 Service Connect 代理程式啟動 TLS,並在目的地代理程式將其終止。因此,應用程式程式碼絕不會看到 TLS 互動。使用下列步驟來驗證 TLS 是否已啟用。
-
在應用程式映像中包含
opensslCLI。 -
在服務上啟用 ECS Exec,以透過 SSM 連線至任務。或者,您也可以在與服務相同的 Amazon VPC 中啟動 Amazon EC2 執行個體。
-
從要驗證的服務中擷取任務的 IP 與連接埠。您可以在 AWS Cloud Map 主控台中擷取任務 IP 地址。該資訊位於命名空間的服務詳細資訊頁面上。
-
使用
execute-command登入任何任務,如下列範例所示。或者,登入在步驟 2 中建立的 Amazon EC2 執行個體。$ aws ecs execute-command --clustercluster-name\ --tasktask-id\ --containercontainer-name\ --interactive \ --command "/bin/sh"注意
直接呼叫 DNS 名稱不會顯示憑證。
-
在已連線的 Shell 中,使用
opensslCLI 來驗證與檢視連接至任務的憑證。範例:
openssl s_client -connect 10.0.147.43:6379 < /dev/null 2> /dev/null \ | openssl x509 -noout -text回應範例:
Certificate: Data: Version: 3 (0x2) Serial Number: <serial-number> Signature Algorithm: ecdsa-with-SHA256 Issuer: <issuer> Validity Not Before: Jan 23 21:38:12 2024 GMT Not After : Jan 30 22:38:12 2024 GMT Subject: <subject> Subject Public Key Info: Public Key Algorithm: id-ecPublicKey Public-Key: (256 bit) pub: <pub> ASN1 OID: prime256v1 NIST CURVE: P-256 X509v3 extensions: X509v3 Subject Alternative Name: DNS:redis.yelb-cftc X509v3 Basic Constraints: CA:FALSE X509v3 Authority Key Identifier: keyid:<key-id> X509v3 Subject Key Identifier: 1D:<id> X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: TLS Web Server Authentication, TLS Web Client Authentication Signature Algorithm: ecdsa-with-SHA256 <hash>