Connecting through TLS in node environment
const Wampy = require('wampy').Wampy;
const w3cws = require('websocket').w3cwebsocket;
wampy = new Wampy('wss://wamp.router.url:8888/wamp-router', {
ws: w3cws,
realm: 'realm1',
additionalHeaders: {
'X-ACL-custom-token': 'dkfjhsdkjfhdkjs',
'X-another-custom-header': 'header-value'
},
wsRequestOptions: {
ca: fs.readFileSync('ca-crt.pem'),
key: fs.readFileSync('client1-key.pem'),
cert: fs.readFileSync('client1-crt.pem'),
host: 'wamp.router.url',
port: 8888,
rejectUnauthorized: false, // this setting allow to connect to untrusted (or self signed) TLS certificate,
checkServerIdentity: (servername, cert) => {
// A callback function to be used (instead of the builtin tls.checkServerIdentity() function)
// when checking the server's hostname (or the provided servername when explicitly set)
// against the certificate. This should return an <Error> if verification fails.
// The method should return undefined if the servername and cert are verified.
if (servername !== 'MyTrustedServerName') {
return new Error('Bad server!');
}
}
}
});Last updated