This is Work in Progress, my enterprise computer decided that roots.exe is dangerous and just removes it so I started looking into an alternative way of getting the root certificates for doing a proper node fetch on windows with ssl.
const fetchAllRootCertificates = async (): Promise<string> => {
const cliPSCommand = `
$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine');
Get-ChildItem -Path Cert:\\LocalMachine\\Root | ForEach-Object {
"-----BEGIN CERTIFICATE-----"
[System.Convert]::ToBase64String($_.RawData, "InsertLineBreaks")
"-----END CERTIFICATE-----"
}
`;
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const { stdout } = await exec(`powershell -Command "${cliPSCommand}"`);
return stdout;
};
I know to little about Certificates however to finish this, maybe it's not possible? Using the above it still says "unable to get local issuer certificate" .. but maybe the names of the certs needs to be included?? or some other