有人知道如何使用pywinrm创建到Windows服务器的HTTPS连接吗
我自己尝试过,但是我无法建立连接
到目前为止我已经完成的步骤:
pip install pywinrm
openssl req -nodes -new -x509 -keyout key.pem -out server.pem
openssl x509 -inform PEM -in server.pem -outform DER -out server.cer
server.cer
(位于“受信任的根证书身份验证”内)注意事项:
现在,我无法建立winrm连接,脚本
import winrm
destination = 'https://10.0.0.1:5986'
username = 'user'
password = 'password'
cert_pem = 'crt-temp/server.pem'
cert_key_pem = 'crt-temp/key.pem'
session = winrm.Session(destination,
auth=(username, password),
transport='certificate',
cert_pem=cert_pem,
cert_key_pem=cert_key_pem)
result = session.run_ps('hostname')
print(result.std_out)
我收到的错误是:
requests.exceptions.SSLError: HTTPSConnectionPool(host='10.0.0.1', port=5986): Max retries exceeded with url: /wsman (Caused by SSLError(SSLCertVerificationError( 1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
如何对此进行故障排除?
这可能是自签名证书的问题,其中签名证书颁发机构不被视为受信任的机构。您可以跳过服务器证书验证,也可以将CA证书添加到客户端计算机上的受信任证书颁发机构
跳过证书验证
向受信任的证书颁发机构添加CA证书
相关问题 更多 >
编程相关推荐