我对 AWS ALB 的 curl 命令不起作用
curl -v --cacert "/filepath/cert.pem" --cert "filepath/cert.pem:password" \
https://xxxxx.us-east-1.elb.amazonaws.com/xxxx/xxxx \
-H "Accept:application/json" \
-H "Content-Type:application/json" \
-H "Host:myhost.com"
Run Code Online (Sandbox Code Playgroud)
给出以下错误:
HTTP/1.1 200 Connection established
* Proxy replied OK to CONNECT request
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /filepath/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to xxx.xxx.us-east-1.elb.amazonaws.com:443
* stopped the pause stream!
* Closing connection 0
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to xxx.xxx.us-east-1.elb.amazonaws.com:443
Run Code Online (Sandbox Code Playgroud)
我也做了 echo | openssl s_client -connect xxx.xxxx.us-east-1.elb.amazonaws.com:443
并且 openssl 返回验证返回码:0 (ok)
我还验证了我的证书上的域名与 alb 侦听器中接受的域名匹配。知道我的请求有什么问题吗?
注意:我也尝试不使用 --cacert 选项并得到相同的结果。
您确定您的 ALB 子网具有包含通过 Internet 网关到 Internet 的路由的路由表吗?如果没有,您将看到连接挂起,如您的问题所示。
我刚刚花了很多时间来追踪同样的问题,结果发现这些缺失的路线就是原因。AWS 控制台会向您发出警告,但不会阻止您。