Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
schatterjee
Partner - Contributor II
Partner - Contributor II

Can't connect to Qlik Engine websocket API using client certificates

Hi,

I am trying to establish a connection to the Qlik engine Websocket API. Referring here: https://help.qlik.com/en-US/sense-developer/August2021/Subsystems/EngineAPI/Content/Sense_EngineAPI/...

I am trying to connect to QlikSense Enterprise from my local computer, using the certificates method. I received the root.pem, client.pem and client_key.pem files from our Qliksense admin. But whenever I am trying to connect, I am receiving this error:

 

Error: self signed certificate in certificate chain
    at TLSSocket.onConnectSecure (_tls_wrap.js:1515:34)
    at TLSSocket.emit (events.js:400:28)
    at TLSSocket._finishInit (_tls_wrap.js:937:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:709:12) {
  code: 'SELF_SIGNED_CERT_IN_CHAIN'
}

 

 This is the nodejs script which I am using:

const WebSocket = require('ws');
const path = require('path')
const fs = require('fs')

// Set certPath to the path to the directory that contains the exported client certificates in PEM format.
var certPath =  path.join('/local-path-to-pem-files/');

var certificates = {
	cert: fs.readFileSync(path.resolve(certPath, 'client.pem')),
	key: fs.readFileSync(path.resolve(certPath, 'client_key.pem')),
	root: fs.readFileSync(path.resolve(certPath, 'root.pem'))
	};

// Open a WebSocket using the engine port (rather than going through the proxy)
// We use the certificates and a built-in Qlik service account
// We connect at the global level, which gives access to APIs in the Global class

	const ws = new WebSocket('wss://<server-name>/app/', {
		ca: [certificates.root],
		cert: certificates.cert,
		key: certificates.key

	});
	
	 ws.onopen = function (event) {
		// send some message
	}
    ws.on('error', function(error) {
        console.log(error);
      });

 Is there anything I am missing? Can someone please help?

Thanks

Labels (2)
2 Replies
Øystein_Kolsrud
Employee
Employee

I guess you need to allow for self signed certificates. There's a thread on the topic for node.js here:

https://stackoverflow.com/questions/45088006/nodejs-error-self-signed-certificate-in-certificate-cha...

schatterjee
Partner - Contributor II
Partner - Contributor II
Author

Thanks,

I saw there is another way to authenticate JSON API, ie, using API key. Will it solve the same purpose? Is this method available for Qliksense Enterprise?