简体   繁体   中英

Electron doesnt execute https call to local spring server, curl works

I'm simply trying to connect to a local Spring configured with SSL / TLS 1.2.

Context (Server): Server is built with Spring, logs when creating a request via curl. Also requires a certificate from the client (X.509 certificate based authentication)

Client (CURL, command-line): Works fine!

Client (Electron): When the code below gets executed nothing happens. No requests are being made to the spring (nothing logs), nor is any error occuring. Nothing. Electron is such a drag to debug..

Code:

let options = {
                hostname: 'localhost',
                port: 8443,
                path: '/',
                cert: fs.readFileSync(global.relativePaths.config + 'client.crt'),
                key: fs.readFileSync(global.relativePaths.config + 'clientprivate.key'),
                passphrase: '[phrase_here]',
                rejectUnauthorized: false,
                requestCert: true
            };
            let request = https.request(options);
            request.on('error', () => {
                console.log("Error!");
            })

Also, this is just localhost, hence the rejectUnauthorized - I'm working with self-signed certificates until ready for production. :)

Thank you in advance. :)

EDIT: using the test-code on the wiki (call to github) outputs with no problem.. what could it be?... also, im doing this on the main process (not on the renderer)

Try using the http-client library like [axios][1] . axios is a promise-based HTTP client for the browser and node.js. It worths giving a try to most used libraries like axios, it's simple to use. If the issue still persists, try setting the User-Agent header in your request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM