<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Engine API - Using websocket.create_connection with Python in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900464#M16378</link>
    <description>&lt;P&gt;Well, as I mentioned, I don't know much about Python, so I'll not be able to help you anymore here. But I do get a couple of hits when I search for the error message you get including this one that with a little luck can help you:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error" target="_blank"&gt;https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2022 09:55:13 GMT</pubDate>
    <dc:creator>Øystein_Kolsrud</dc:creator>
    <dc:date>2022-03-03T09:55:13Z</dc:date>
    <item>
      <title>Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899367#M16369</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm using the following Python script to connect to a Qlik Sense Enterprise Server (aka &lt;EM&gt;myserver&lt;/EM&gt;) :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;import websocket, json, ssl&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;ssl.match_hostname = lambda cert, hostname: True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;websocket.enableTrace(True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;ws = websocket.create_connection('wss://myserver/app/', sslopt={"cert_reqs": ssl.CERT_NONE}, header={"X-Qlik-User": "UserDirectory=INTERNAL; UserId=sa_engine"})&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Result of the trace :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;--- request header ---&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;GET /app/ HTTP/1.1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Upgrade: websocket&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Host: myserver&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Origin: &lt;A href="https://myserver" target="_blank"&gt;https://myserver&lt;/A&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Sec-WebSocket-Key: zn7kGce6liKC/nO9Xib3Xw==&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Sec-WebSocket-Version: 13&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Connection: Upgrade&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;X-Qlik-User: UserDirectory=RATP; UserId=X2027531&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;-----------------------&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;--- response header ---&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;HTTP/1.1 101 Web Socket Protocol Handshake&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Upgrade: WebSocket&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Connection: Upgrade&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Sec-WebSocket-Accept: QkiegGxJWQshniYccw2ibjuLpJM=&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I'm trying to get list of apps using the following Python instructions :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;params='''{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;"handle": -1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;"method": "GetDocList",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;"params": [],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;"outKey": -1,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;"id": 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;}'''&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;ws.send(params)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;print ("Sent")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;print ("Receiving...")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;result = ws.recv()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;print ("Received GetDocList '%s'" % result)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am expecting the list of apps but I always get the same answer from the server :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;{"jsonrpc":"2.0","method":"OnAuthenticationInformation","params":{"loginUri":"&lt;A href="https://myserver:443/internal_forms_authentication/?targetId=444d4b95-afd1-41b0-88ba-ee2014ecee3e" target="_blank"&gt;https://myserver:443/internal_forms_authentication/?targetId=444d4b95-afd1-41b0-88ba-ee2014ecee3e&lt;/A&gt;","mustAuthenticate":true}}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Laurent&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 14:07:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899367#M16369</guid>
      <dc:creator>l_robin</dc:creator>
      <dc:date>2022-03-02T14:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899378#M16370</link>
      <description>&lt;P&gt;Qlik Sense will sometimes send push notifications. When you connect to the engine through the Proxy, the first messages you get on the websocket is typically the one you are referring to. It is a push method that indicates your authentication status. The property "mustAuthenticate" is set to "true" in your case which indicates that you have not yet been correctly authenticated.&lt;/P&gt;&lt;P&gt;The use of the user INTERNAL\sa_engine requires you to do a direct connection to the engine using certificates. Have you attached the Qlik client certificate to your request? And also, you'll need to connect directly to the engine port (typically 4747) in this case.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 14:16:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899378#M16370</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2022-03-02T14:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899470#M16372</link>
      <description>&lt;P&gt;Hello Yko,&lt;/P&gt;
&lt;P&gt;Thanks for your prompt answer.&lt;/P&gt;
&lt;P&gt;Using the certificates exported with the QMC, I have tried the below script, where &lt;EM&gt;privatekeypath&lt;/EM&gt; is the folder where the certificates are stored :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;privateKeyPath='c:\\tmp\\'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;url = 'wss://myserver:4747/app/'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;certs = ({"ca_certs": privateKeyPath + "root.pem", "certfile": privateKeyPath + "client.pem", "keyfile": privateKeyPath + "client_key.pem", "cert_reqs": ssl.CERT_REQUIRED, "server_side": False})&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;ws = websocket.create_connection(url, sslopt=certs, header={"X-Qlik-User": "UserDirectory=INTERNAL; UserId=sa_engine"})&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Unfortunately, there is a problem with the certificates and I get the following error :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate (_ssl.c:997)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Laurent&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 16:07:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1899470#M16372</guid>
      <dc:creator>l_robin</dc:creator>
      <dc:date>2022-03-02T16:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900373#M16374</link>
      <description>&lt;P&gt;I have never use Python for communicating with Qlik Sense before, so I'm probably not the best person to continue helping you on this, but did you disable the certificate validation in this second scenario? I saw you added the line "&lt;FONT face="courier new,courier" size="2"&gt;ssl.match_hostname&lt;/FONT&gt;" in your first post, but not your second (but perhaps you just excluded that part). I'm asking because error message you get indicates that you are running into exactly the type of validation error that the "match_hostname" property disables. Also this page indicates that the "match_hostname" is the solution for this:&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/49257450/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c" target="_blank"&gt;https://stackoverflow.com/questions/49257450/ssl-sslerror-ssl-certificate-verify-failed-certificate-verify-failed-ssl-c&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 07:26:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900373#M16374</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2022-03-03T07:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900427#M16377</link>
      <description>&lt;P&gt;Yes,&amp;nbsp; I forgot to add it to my previous post but the following line is in my Python script :&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;ssl.match_hostname = lambda cert, hostname: True&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;But despite this, I still get the same error message :&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: invalid CA certificate (_ssl.c:997)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 08:47:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900427#M16377</guid>
      <dc:creator>l_robin</dc:creator>
      <dc:date>2022-03-03T08:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Engine API - Using websocket.create_connection with Python</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900464#M16378</link>
      <description>&lt;P&gt;Well, as I mentioned, I don't know much about Python, so I'll not be able to help you anymore here. But I do get a couple of hits when I search for the error message you get including this one that with a little luck can help you:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error" target="_blank"&gt;https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 09:55:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Engine-API-Using-websocket-create-connection-with-Python/m-p/1900464#M16378</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2022-03-03T09:55:13Z</dc:date>
    </item>
  </channel>
</rss>

