Question

I'm testing my NodeJS application with supertest. My application is asking for a certificate, with the CN of the certificate my user gets authorized against the application.

While testing my first route, I got an error complaining about my self signed certificate.

I wonder if there is a way to set a valid or invalid certificate while testing my routes?

Was it helpful?

Solution

On Node.js, TLS and HTTPS will validate certificates before accepting them. Therefore, to use self-signed certificates with Node, you will need to set the rejectUnauthorized option when performing requests to false, or use:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

Here's an old pull request that pertains to this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top