【问题标题】:Connecting using Pywinrm with ssl使用 Pywinrm 和 ssl 连接
【发布时间】:2016-05-15 01:03:18
【问题描述】:

我遵循了 Matt Wrock 非常有用的指南:Understanding and Troubleshooting WinRM connection and authentication, (http://www.hurryupandwait.io/blog/understanding-and-troubleshooting-winrm-connection-and-authentication-a-thrill-seekers-guide-to-adventure) 并且我能够在我的远程计算机上设置 SSL 连接,我使用以下方法进行了验证:

Test-WSMan -ComputerName "My DNS" -UseSSL

... 返回非错误消息。我也可以从 powershell 连接:

Enter-PSSession -ComputerName "My DNS" -Credential $cred -UseSSL

但是,当我运行以下 python 代码时:

import winrm

s = winrm.Session('My DNS', auth=('Remote Username', 'Remote Password'), transport='ssl')
r = s.run_cmd('ipconfig', ['/all'])

... 我收到以下错误代码: winrm.exceptions.WinRMTransportError: 500 WinRMTransport。 [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:590)

证书验证失败错误让我认为我错误地配置了 SSL 配置;但是,我似乎可以从 Powershell 进行连接。

谁能告诉我我做错了什么或如何使用 ssl 正确连接?

感谢您的宝贵时间

【问题讨论】:

    标签: python ssl winrm


    【解决方案1】:

    发现 pywinrm 版本存在问题。

    使用 python 版本 2.7.10 和 pywinrm 版本 (0.1.1)。它工作正常,没有任何错误。

    即使我们在脚本中放置异常处理程序以忽略证书,最新版本也会强制验证 ssl 证书。

    【讨论】:

    • 再次检查自签名证书的过期状态,如果过期,则创建新的自签名证书并将其复制到受信任的根证书颁发机构证书存储中。
    猜你喜欢
    • 2017-09-14
    • 1970-01-01
    • 2013-09-21
    • 2020-06-19
    • 1970-01-01
    • 2015-09-05
    • 2019-08-14
    • 1970-01-01
    • 2022-11-21
    相关资源
    最近更新 更多