Sch*_*hLx 6 windows ssl openssl azure
我在配置 Windows 以使用az
命令行工具时遇到一些问题。我测试了多种配置。一种是本地安装的系统,另一种是基于 Windows 的 docker 容器。我在两个系统上都遇到相同的错误。
如果我发出以下命令:
az login --tenant my-domain.org
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
HTTPSConnectionPool(主机='login.microsoftonline.com',端口=443):超过最大重试次数,网址:/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
Run Code Online (Sandbox Code Playgroud)
本地系统有以下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
Run Code Online (Sandbox Code Playgroud)
我试图理解为什么会出现错误,所以我测试了与 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
Run Code Online (Sandbox Code Playgroud)
我还使用相同的代理服务器和 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",
...
Run Code Online (Sandbox Code Playgroud)
在 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
Run Code Online (Sandbox Code Playgroud)
我还根据此链接使用以下命令导入了证书:
PS C:\azp> Import-Certificate -FilePath .\BB-CA-DD.crt -CertStoreLocation Cert:\LocalMachine\Root\
Run Code Online (Sandbox Code Playgroud)
没有变化。我不知道如何继续。
也许这个问题与以下帖子和文章有关:
编辑:
我已将解决方案从此处移至答案块,以突出显示我的问题已解决。根据反应,我得出结论,它确实对其他人也有用。
最后我能够解决这个问题,如下所示:
我找到了以下文档:
在 Azure Stack 开发工具包上为 Azure CLI 设置证书
基本思想是找到用于 Azure CLI 的 python 安装并更新相关的证书文件。
在我的例子中,Azure CLI 与 python 一起安装在以下位置:
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe
并使用建议的命令,返回如下:
PS > & "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe" -c "import certifi; print(certifi.where())"
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\lib\site-packages\certifi\cacert.pem
Run Code Online (Sandbox Code Playgroud)
Azure CLI 的 64 位变体将使用如下所示的不同文件夹:
C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\certifi\cacert.pem
更新上述文件az login
为我解决了这个问题。提供的 python 安装之一my-domain.org
包含正确配置的 cacert.pem 文件。
归档时间: |
|
查看次数: |
16738 次 |
最近记录: |