bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 9 forks source link

ntlm-auth PROXY_TO_SERVER_REQUEST_ERROR on /: Error: self signed certificate #174

Closed GanjiguntePriyanka closed 3 years ago

GanjiguntePriyanka commented 3 years ago

Hi, I am trying to integrate ntlm-auth with Cypress & I am getting 504 error. My setup is simple: Packages used: "cypress": "^7.5.0", "cypress-ntlm-auth": "^3.2.2"

Added this command to support.js: import "cypress-ntlm-auth/dist/commands";

Test: cy.ntlm(["lon-testhost-d10.xxx.com:4200"], "user1abc", "passabc!","xxx"); cy.visit('https://lon-testhost-d10.xxx.com:4200/')

I am getting below error:

cypress:plugin:ntlm-auth Request to https://lon-testhost-d10.xxx.com:4200/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth PROXY_TO_SERVER_REQUEST_ERROR on /: Error: self signed certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1531:34) at TLSSocket.emit (node:events:378:20) at TLSSocket._finishInit (node:_tls_wrap:945:8) at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:719:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT'

cypress-ntlmLog.txt

I have api request as well which goes through same authentication process. (Just as a comparison I used postman and the request goes through fine in postman. eg: // var testUrl = 'https://lon-testhost-d10.xxx.com:4200/api/auth/auth-user'; // var options = { // method: "GET", // url: testUrl, // auth: { // type: "ntlm", // ntlm: { // username: "user1abc", // password: "passabc!" // } // } // }; // //console.log(testUrl)

// pm.sendRequest(options, function (error, response) { // var jsonData = response.json(); // pm.globals.set('token',jsonData.token) // console.log(jsonData.token) // } // ); This same request is having issues in Cypress. Is there any other setup which I need to do for Cypress to work with ntlm auth?

bjowes commented 3 years ago

Yes, the plugin will not accept certificates from untrusted sources. See this section in the docs https://github.com/bjowes/cypress-ntlm-auth#httpsssltls-issues

For a more detailed description, I discussed this during a conference session at NDC Oslo. The full talk is available here: https://youtu.be/gpT8uieBqX0

GanjiguntePriyanka commented 3 years ago

Thank you! We are getting the certificates sorted. As suggested in the docs above, using chromewebsecurity:false and setting NODE_TLS_REJECT_UNAUTHORIZED to 0 is working fine in local environment.