-1

I'm trying to connect Qlik sense API editor through Python with below code and I'm getting below error.

OS : Mac Pyton version : 3.X

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 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)

There is similar question in StackOverFlow but there is no clear answer how it git resolved. Can anyone help here please ?

Dushan
  • 71
  • 1
  • 4
  • Possible duplicate of [Python SSL CERTIFICATE\_VERIFY\_FAILED](https://stackoverflow.com/questions/28858634/python-ssl-certificate-verify-failed). The Answer clearly explains why! – stovfl Oct 08 '18 at 09:15
  • I meant this https://stackoverflow.com/questions/49257450/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c?noredirect=1&lq=1 as not clearly explained. Still I'm getting the same error. – Dushan Oct 08 '18 at 15:53
  • Relevant [Mac OSX python ssl.SSLError: \[SSL: CERTIFICATE_VERIFY_FAILED\] certificate verify failed (_ssl.c:749)](https://stackoverflow.com/questions/41691327/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c?rq=1) – stovfl Oct 08 '18 at 16:45

1 Answers1

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

just try with these if it will Help you. Change **CERT_REQUIRED** into **CERT_NONE**

Vaibhav Vishal
  • 6,576
  • 7
  • 27
  • 48