Websocket API authentication with certificates

Hi,
I am trying to connect to websocket which requires authentication using certificates (Qlik Engine JSON API to be specific). I do have certificates generated and stored in my computer (pem files), the questions is if the websocket package supports such authentication and how to do it (no luck with documentation or googling everywhere possible). Basically, I need to rework this JavaScript to R. Is that possible? Thank you for any hints and help.

const WebSocket = require('ws');

...

// Set certPath to the path to the directory that contains the exported client certificates in PEM format.
var certPath =  path.join('C:', 'ProgramData', 'Qlik', 'Sense', 'Repository', 'Exported Certificates', '.Local Certificates');

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.domain.com:4747/app/', {
		ca: [certificates.root],
		cert: certificates.cert,
		key: certificates.key,
		headers: {
			'X-Qlik-User':  'UserDirectory=internal; UserId=sa_engine'
		}

	});
	
	 ws.onopen = function (event) {
		// send some message
	}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.