0

I'm very new to JavaScript so I'm hoping this is not a stupid question.

I have searched this site and the internet but cannot find the answer. I am trying to replicate a Python request.get() (which is working) in a JavaScript request. The python is:

requests.get(url, auth=(username, password), cert="path/to/certificate.pem")

My JavaScript is as follows currently:

fetch(url, {
  headers: {
    Authorization: `Basic ${btoa(username + ":" + password)}`
  },
  method: GET
})

How do I load the .pem certificate into the request?

Many thanks.

EDIT:

My apologies @Random Davis I thought specifying I'd searched this site was enough of an indication I hadn't found anything I was looking for. Please see below and the edited title.

To clarify I am not using node.js. Or at least I am unaware that I am using it as I am just utilising local files (HTML/CSS/JavaScript). As far as I can tell every single other answer here is node.js related and requires importing(??requiring??) external libraries. I am trying to avoid this.

Obviously if it is not possible without node.js and the external libraries I will have to think about using them. Due to my lack of knowledge with the JS/Node stack I am unaware if these requests can be done with just vanilla JS.

Again may thanks for any help.

sylph
  • 115
  • 1
  • 9
  • [this post](https://stackoverflow.com/questions/57664133/how-to-send-a-post-request-and-authenticate-with-a-pem-certificate-and-passphra) has links to a lot of related existing questions...what are you asking that those posts don't cover? I'm assuming you already looked at those when researching, but you didn't mention making any attempt at research whatsoever so I'm not sure if I just wasted my time or not. In the future you might want to make it clear what you've looked up already, so people don't waste their (and your) time with solutions you've already tried. – Random Davis May 10 '22 at 16:20

0 Answers0