smollweide / node-mock-server

File based Node REST API mock server
MIT License
255 stars 65 forks source link

Tunnels with https target #134

Closed sebastienfouache closed 4 years ago

sebastienfouache commented 5 years ago

Hello, i m tunnelling calls to real enpoints but https look to crash if certificats not valid or self signed.

✖ Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket._finishInit (_tls_wrap.js:636:8)

Hint : https://stackoverflow.com/questions/46968937/nodejs-request-post-not-working-for-https-website/46968984#46968984

sebastienfouache commented 5 years ago

@smollweide any suggestion ?

Could we add an option to avoid certificat check in tunnelling ?

tunnel: {
        protocol: 'https',
        authUser: undefined,
        authPass: undefined,
        host: 'localhost',
        port: 3333,
        no-check-certificate: true, // <-- 
        requestHeaders: {
            host: 'www.test.com',
            referer: "http://www.test.com/",
        },
    }
smollweide commented 5 years ago

Hi Sebastien, thanks. Feel free to add a PR

smollweide commented 4 years ago

Hi Sebastien, that's not secure but you can add this in the mock server js file:

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;