I finally have found a solution that works with VS Code for those who still run into issues using win-ca.
For those who use things including GitHub Copilot have a odd reason of not respecting NODE_EXTRA_CA_CERTS system variable and therefore need a little bit more work.
If you already have a .pem file ignore this step and move forward.
Go to your choice of browser and go to: github.com
Exporting the certificate as a Base64-encoded ASCII, certificate chain and making sure the extension of the file ends with .pem
Then, setting NODE_EXTRA_CA_CERTS variable into user variable (If set as a System Var will not work) with your included .pem file.
After adding the user variable, go to your VS Code installation and finding the Github Copilot extension folder and then going under the /dist directory.
Open extension.js
file in a code editor and add this code to the top of the extensions file.
const tls = require("tls");
const fs = require("fs");
const origCreateSecureContext = tls.createSecureContext;
tls.createSecureContext = options => {
const context = origCreateSecureContext(options);
const pem = fs
.readFileSync(process.env.NODE_EXTRA_CA_CERTS, { encoding: "ascii" })
.replace(/\r\n/g, "\n");
console.log(pem);
const certs = pem.match(/-----BEGIN CERTIFICATE-----\n[\s\S]+?\n-----END CERTIFICATE-----/g);
if (!certs) {
throw new Error(`Could not parse certificate ${process.env.NODE_EXTRA_CA_CERTS}`);
}
certs.forEach(cert => {
context.context.addCACert(cert.trim());
});
return context;
};
This forces Github Copilot to add self signed certificates and lets it work under proxies and Corporate networks.