Qlik感ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:749)

时间:2018-10-08 08:29:17

标签: python openssl qliksense

我正在尝试使用以下代码通过Python连接QlikSense API编辑器,但出现错误。

OS:Mac Pyton版本:3.X

ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:749)

from websocket import create_connection
import ssl


senseHost = "HOST1"
privateKeyPath = "/Users/ABC"


## userDirectory and userId can be found at QMC -> Users
userDirectory, userId = "DIR", "user1"

url = "wss://" + senseHost + ":443/app"  # valid
certs = ({"ca_certs": privateKeyPath + "root.pem",
          "certfile": privateKeyPath + "client.pem",
          "keyfile": privateKeyPath + "client_key.pem",
          "cert_reqs": ssl.CERT_REQUIRED,
          "server_side": False
          })
ssl.match_hostname = lambda cert, hostname: True
ws = create_connection(url, sslopt=certs,
                       header={'X-Qlik-User: UserDirectory=%s; UserId=%s' % (userDirectory, userId)})

print ("connetced")

session = ws.recv()

print (session)

StackOverFlow中也有类似的问题,但是没有明确的答案来解决git。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

certs = ({"ca_certs": privateKeyPath + "root.pem",
          "certfile": privateKeyPath + "client.pem",
          "keyfile": privateKeyPath + "client_key.pem",
          "cert_reqs": ssl.CERT_NONE,
          "server_side": False
          })

只要有帮助,请尝试这些。将**CERT_REQUIRED**更改为**CERT_NONE**