Connecting using Pywinrm with ssl

孤人 提交于 2019-12-12 16:41:05

问题


I followed Matt Wrock's very helpful guide: 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) and I was able to set up an SSL connection on my remote machine, which I verified using:

Test-WSMan -ComputerName "My DNS" -UseSSL

... which returned a non-error message. And I can also connect from powershell:

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

However, when I run the following python code:

import winrm

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

... I get receive the following error code: winrm.exceptions.WinRMTransportError: 500 WinRMTransport. [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

The certificate verify failed error makes me think that I improperly configured the SSL configuration; however, I seem to be able to connect from Powershell.

Can anybody tell me what I am doing wrong or how to properly connect using ssl?

Thanks for your time


回答1:


Problem found with the pywinrm version.

Use python version 2.7.10 and pywinrm version (0.1.1). It Worked fine without any error.

Latest version forcibly verifying the ssl certificate even we put exception handlers to ignore certificate in the script.



来源:https://stackoverflow.com/questions/35217606/connecting-using-pywinrm-with-ssl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!