Stefan Stoychev
Stefan Stoychev

Reputation: 5012

Node https.Agent in browser

Part of my npm module (typescript) is using axios to make web requests. One of the possible endpoints is using certificates for authentication. For this scenario I'm passing new https.Agent to axios to send the certificates info. All is working fine if the module is used from within Node app.

The problem is if I try and use my module in browser environment. When in browser https module do not exists and I'm unable to use my module.

Upvotes: 4

Views: 3418

Answers (1)

Robert Kawecki
Robert Kawecki

Reputation: 2448

You can't do it. Most browsers support TLS Client Certificate authentication, but it works differently: the user is presented with a window and asked to select a certificate to authenticate with. It's a similar story to how cookies work - you can't easily manipulate HttpOnly cookies from JS on the client side.

If you want TLS client auth in the browser, you are at the browser vendor's mercy.

Upvotes: 3

Related Questions