Websocket catch ERRO[0001] GoError: x509: certificate signed by unknown authority

Hello,
I need to use wss Websoket with cookies and headers like

const url = “wss://ip:443/user/ws/mmprices/034/yexxyxnj/websocket”;
const cookies = {
my_cookie: {
value: ‘CSRF-TOKEN=value; ip_AN=value; ip_CUSTOMER=value=’,

},

};
const params = {
headers: {
“X-Requested-With”: “XMLHttpRequest”,
“Cache-Control”: “max-age=0”,
“Accept”: “/”,
“Referer”: “https://ip/user/”,
“Accept-Language”: “en-US,en;q=0.5”,
“Accept-Encoding”: “gzip, deflate, br”,
“Content-Type”: “application/json”
}
};

const response = ws.connect(url, cookies, params, function(socket) {

but catch ERRO[0001] GoError: x509: certificate signed by unknown authority

If directly using the correct domain instead of the IP is not an option, try using the hosts k6 option:

export let options = {
  hosts: {
    '<domain-for-which-the-certificate-is>': '<ip-you-were-using-in-your-test>',
  },
};

If that won’t work, because you’re using a self-signed certificate or something like that, you can use the insecureSkipTLSVerify k6 option to tell k6 not to do any TLS certificate validation whatsoever.

I am using direct domain. But posted here as ‘ip’ because of security reason.

@LiliiaK using the insecureSkiptTLSVerify option should still apply, although I have to say that if you need to pass some cookie in order to make the http request you aren’t going to be able because k6 just doesn’t support this for websocket connections … yet, sorry :frowning: