@@ -18,15 +18,26 @@ opensslTest("NODE_EXTRA_CA_CERTS: loads certificates", async ({ expect }) => {
1818
1919 // Generate self-signed certificate
2020 childProcess . execSync (
21- 'openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 30 -out cert.pem -subj "/CN=localhost"' ,
21+ 'openssl req -newkey rsa:2048 -nodes -keyout ca-key.pem -x509 -days 30 -out ca.pem -subj "/CN=Test CA"' ,
22+ { cwd : tmp , stdio : "ignore" }
23+ ) ;
24+ childProcess . execSync (
25+ 'openssl req -newkey rsa:2048 -nodes -keyout key.pem -out cert.csr -subj "/CN=localhost"' ,
26+ { cwd : tmp , stdio : "ignore" }
27+ ) ;
28+ await fs . writeFile (
29+ path . join ( tmp , "extensions.cnf" ) ,
30+ "subjectAltName=DNS:localhost\nbasicConstraints=critical,CA:FALSE\nextendedKeyUsage=serverAuth\n"
31+ ) ;
32+ childProcess . execSync (
33+ "openssl x509 -req -in cert.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -days 30 -out cert.pem -extfile extensions.cnf" ,
2234 { cwd : tmp , stdio : "ignore" }
2335 ) ;
2436 const keyPath = path . join ( tmp , "key.pem" ) ;
2537 const certPath = path . join ( tmp , "cert.pem" ) ;
2638 const key = await fs . readFile ( keyPath ) ;
2739 const cert = await fs . readFile ( certPath ) ;
2840
29- // Start HTTPS server with self-signed certificate
3041 const responseBody = "secure body" ;
3142 const server = https . createServer ( { key, cert } , ( req , res ) => {
3243 res . end ( responseBody ) ;
@@ -47,7 +58,10 @@ opensslTest("NODE_EXTRA_CA_CERTS: loads certificates", async ({ expect }) => {
4758 // Write NODE_EXTRA_CA_CERTS file, with multiple certificates
4859 // (see https://github.com/cloudflare/miniflare/pull/587/files#r1271579671)
4960 const caCertsPath = path . join ( tmp , "bundle.pem" ) ;
50- const caCerts = [ ...tls . rootCertificates , cert ] ;
61+ const caCerts = [
62+ ...tls . rootCertificates ,
63+ await fs . readFile ( path . join ( tmp , "ca.pem" ) ) ,
64+ ] ;
5165 await fs . writeFile (
5266 caCertsPath ,
5367 [ "## This is a comment which should be ignored\n" ] . concat (
0 commit comments