NiBurhe
NiBurhe

Reputation: 103

Protractor Remote Seleniumbox: SELF_SIGNED_CERT_IN_CHAIN error

we are running a remote Seleniumbox and want to run our test on it. The Certificate of the address of remote selenium is self signed by the company. I have the root certificates, but no idea to include them. I already tried to use options like npm ca, --ignore-ssl-strict, etc. also set capabilities, but nothing works. It looks like all these settings are for the connection between seleniumbox and test site. But I have the certificate problem earlier, when the build server want to connect to seleniumbox.

[08:59:28] I/update - chromedriver: chromedriver_88.0.4324.96.exe up to date
[08:59:28] I/launcher - Running 1 instances of WebDriver
[08:59:28] I/hosted - Using the selenium server at https://seleniumbox.xxxxxxxx.xx/wd/hub
[08:59:28] E/launcher - SELF_SIGNED_CERT_IN_CHAIN self signed certificate in certificate chain
[08:59:28] E/launcher - Error: SELF_SIGNED_CERT_IN_CHAIN self signed certificate in certificate chain
    at ClientRequest.<anonymous> (XXX\node_modules\selenium-webdriver\http\index.js:238:15)
    at ClientRequest.emit (events.js:223:5)
    at TLSSocket.socketErrorListener (_http_client.js:406:9)
    at TLSSocket.emit (events.js:223:5)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
From: Task: WebDriver.createSession()
    at Function.createSession (XXX\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
    at Function.createSession (XXX\node_modules\selenium-webdriver\chrome.js:761:15)
    at createDriver (XXX\node_modules\selenium-webdriver\index.js:170:33)
    at Builder.build (XXX\node_modules\selenium-webdriver\index.js:626:16)
    at Hosted.getNewDriver (XXX\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
    at Runner.createBrowser (XXX\node_modules\protractor\built\runner.js:195:43)
    at XXX\node_modules\protractor\built\runner.js:339:29
    at _fulfilled (XXX\node_modules\protractor\node_modules\q\q.js:834:54)
    at XXX\node_modules\protractor\node_modules\q\q.js:863:30
    at Promise.promise.promiseDispatch (XXX\node_modules\protractor\node_modules\q\q.js:796:13)
[08:59:28] E/launcher - Process exited with error code 199

Anybody has an idea?

Thanks & Regards

Upvotes: 1

Views: 428

Answers (1)

PDHide
PDHide

Reputation: 19949

you can turn off ssl validation as

npm config set strict-ssl false

But this is not recommended , instead add the root certificate to the certificate chain . To do so follow the below steps. When ever you want to add a different root create the corresponding cer file of that root and copy the content and add it at the end of your crt file.

Steps:

Save certificate:

open https://seleniumbox.xxxxxxxx.xx/wd/hub in chrome

click lock icon > click view certificate

click certification path > click root > Click view certificate

CLick details ,> Click copy to file > select base 64 cert.cer

save it as cert.cer

Npm config:

npm config set cafile "C:<pathto>\cert.cer"

Update:

Try using :

SET NODE_EXTRA_CA_CERTS="C:\<pathto>\cert.cer"

or

dissable tls all together (not recommended)

SET NODE_TLS_REJECT_UNAUTHORIZED=0

This will stop unauthorized tls from being rejected

Upvotes: 1

Related Questions