【发布时间】:2021-12-01 01:52:03
【问题描述】:
我在配置我的 Windows 以使用 az 命令行工具时遇到了一些问题。我已经测试了多种配置。一个在本地安装的系统上,一个在基于 Windows 的 docker 容器上。我在两个系统上都遇到了同样的错误。
如果我发出以下命令:
az login --tenant my-domain.org
我收到以下错误:
HTTPSConnectionPool(host='login.microsoftonline.com', port=443):最大重试次数超出了 url:/my-domain.org/.well-known/openid-configuration(由 SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中的自签名证书 (_ssl.c:1125)')))
容器有以下az和openssl版本:
PS C:\azp> az version
{
"azure-cli": "2.28.0",
"azure-cli-core": "2.28.0",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
PS C:\azp> openssl version
OpenSSL 1.1.1k 25 Mar 2021
本地系统有以下az和openssl版本:
(base) PS C:\01_Dev\dockerdevimage> az version
{
"azure-cli": "2.26.1",
"azure-cli-core": "2.26.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
(base) PS C:\01_Dev\dockerdevimage> openssl version
OpenSSL 1.1.1c 28 May 2019
我试图了解为什么会出现错误,因此我测试了与 openssl 的连接,如下所示:
PS C:\azp> openssl s_client -proxy 10.76.209.147:3128 -connect login.microsoftonline.com:443 -showcerts
CONNECTED(00000180)
Can't use SSL_get_servername
depth=2 DC = org, DC = my-domain, CN = PKI, CN = BB-CA-DD <-- edited manually
verify error:num=19:self signed certificate in certificate chain
verify return:1
我还使用相同的代理服务器和 Linux 容器进行了测试,并且 az 命令按预期工作:
$ az version
{
"azure-cli": "2.25.0",
"azure-cli-core": "2.25.0",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
$ openssl version
OpenSSL 1.1.1f 31 Mar 2020
$ az login --tenant my-domain.org
The default web browser has been opened at https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/oauth2/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
You have logged in. Now let us find all the subscriptions to which you have access...
[
{
"cloudName": "AzureCloud",
...
在 Linux 容器上,openssl 命令返回以下输出:
$ openssl s_client -proxy 10.76.209.147:3128 -connect login.microsoftonline.com:443 -showcerts
Can't use SSL_get_servername
depth=2 DC = org, DC = my-domain, CN = PKI, CN = BB-CA-DD
verify return:1
我还基于this link使用以下命令导入了证书:
PS C:\azp> Import-Certificate -FilePath .\BB-CA-DD.crt -CertStoreLocation Cert:\LocalMachine\Root\
没有变化。我不确定如何继续。
这个问题可能与以下帖子和文章有关:
- Can OpenSSL on Windows use the system certificate store?
- How to Use OpenSSL with a Windows Certificate Authority to Generate TLS Certificates
- Installing TLS / SSL ROOT Certificates to non-standard environments
编辑:
我已将解决方案从此处移至答案块,以强调我的问题已解决。根据反应,我得出结论,它确实对其他人也有用。
【问题讨论】: