mirror of
https://github.com/avwo/whistle.git
synced 2026-10-29 15:09:28 +08:00
refactor: Refine generate certificate
This commit is contained in:
+9
-2
@@ -40,13 +40,13 @@ function getMacAddress() {
|
||||
}
|
||||
|
||||
function createCertificate(hostname) {
|
||||
var cert = customPairs[hostname]
|
||||
var cert = customPairs[hostname]
|
||||
|| wildcardPairs[hostname.slice(hostname.indexOf('.'))]
|
||||
|| cachePairs[hostname];
|
||||
if (cert) {
|
||||
return cert;
|
||||
}
|
||||
|
||||
|
||||
cert = createCert(pki.setRsaPublicKey(ROOT_KEY.n, ROOT_KEY.e),
|
||||
crypto.createHash('sha1')
|
||||
.update(hostname, 'binary')
|
||||
@@ -58,6 +58,13 @@ crypto.createHash('sha1')
|
||||
}]);
|
||||
|
||||
cert.setIssuer(ROOT_CRT.subject.attributes);
|
||||
cert.setExtensions([ {
|
||||
name: 'subjectAltName',
|
||||
altNames: [{
|
||||
type: 2,
|
||||
value: hostname
|
||||
}]
|
||||
} ]);
|
||||
cert.sign(ROOT_KEY, forge.md.sha256.create());
|
||||
cert = cachePairs[hostname] = {
|
||||
key: pki.privateKeyToPem(ROOT_KEY),
|
||||
|
||||
Reference in New Issue
Block a user