考虑 nginx 的参数proxy_ssl_verify,proxy_ssl_trusted_certificate这些参数用于保护与上游服务器的通信。
# downstream server: nginx.conf
stream {
server {
# ...
proxy_ssl on;
proxy_ssl_verify on;
proxy_ssl_trusted_certificate /etc/nginx/ssl/upstream.example.com/chain.pem;
proxy_ssl_verify_depth 2;
}
}
Run Code Online (Sandbox Code Playgroud)
我的印象是,对于,proxy_ssl onnginx 会根据upstream.example.com.proxy_ssl_trusted_certificate
但是,我遇到了一个问题,nginx 无法与上游服务器建立安全连接,并报告上游 SSL 证书验证错误: (2:unable to get Issuercertificate) while SSL 与上游握手,同时使用以下命令验证证书openssl确实有效。
# fullchain.pem: certificate sent by the upstream server
# chain.pem: CA certificate for `proxy_ssl_trusted_certificate`
# openssl verify -CAfile chain.pem fullchain.pem
fullchain.pem: OK
Run Code Online (Sandbox Code Playgroud)
这让我想知道nginx实际上是如何进行验证的。有没有办法单独重现此问题,以便调试为什么会发生错误?
https://nginx.org/en/docs/http/ngx_http_proxy_module.html
proxy_ssl_verify 上 | 离开;启用或禁用代理 HTTPS 服务器证书的验证。
proxy_ssl_verify_depth 数字;设置代理 HTTPS 服务器证书链中的验证深度。
proxy_ssl_trusted_certificate 文件;指定具有 PEM 格式的可信 CA 证书的文件,用于验证代理 HTTPS 服务器的证书。
正如文档所述,proxy_ssl_trusted_certificate期望使用 CA 证书来验证上游服务器的 TLS 证书。您似乎已经提供了上游服务器的 TLS 证书链。请提供 CA 证书。
| 归档时间: |
|
| 查看次数: |
13934 次 |
| 最近记录: |