How to fetch() with ssl client authentication?

3.9k views Asked by At
  • Background: I am building a chrome extension that sends a simple http request and should be able to work with ssl client authentication.
  • Goal: Send a fetch request to a site with ssl client authentication without user having to open the site first.
  • What happens so far:
    • The request is only successful after i open the site manually.
    • Attempted using credentials: 'include' as suggested here - didn't solve the issue.
    • Im getting TypeError: failed to fetch
  • Fetch API docs @ Mozilla don't seem to mention this (here and here)

fetch is sent as follows:

    fetch(url)
        .then(response => {
            if(!response.ok){
                throw Error("Http request failed");
            }else{
                return response
            }
        })
        .then(response => response.text())
        .then(validate => validate.replace(/\D/g,''))
        .then(count => {
            chrome.action.setBadgeText({text: count});
            if(callback){
                callback();
            }
        })
        .catch(error => {
            console.log(error)
            if(callback){
                callback();
            }
        });

I would be very grateful if you could guide me on what might be the issue.

As this is was not resolve for a couple of years or so, i opened a bug at the chromium bug tracker

0

There are 0 answers