Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

https-cert

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

https-cert - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

177

index.js

@@ -17,97 +17,104 @@ "use strict";

const CAKEYOBJ = forge.pki.privateKeyFromPem(CAKEY);
const signSync = function (domain) {
let subject = [
{
name: "commonName",
value: domain
},
{
name: "countryName",
value: "CN"
},
{
shortName: "ST",
value: "ZJ"
},
{
name: "localityName",
value: "HZ"
},
{
name: "organizationName",
value: "Alibaba"
},
{
shortName: "OU",
value: "FE"
}
];
module.exports = {
root: CACERT,
path: CACERTPATH,
sign: function (domain, cb) {
let subject = [
{
name: "commonName",
value: domain
},
{
name: "countryName",
value: "CN"
},
{
shortName: "ST",
value: "ZJ"
},
{
name: "localityName",
value: "HZ"
},
{
name: "organizationName",
value: "Alibaba"
},
{
shortName: "OU",
value: "FE"
}
];
// 生成证书签发请求
let csr = forge.pki.createCertificationRequest();
// 生成证书签发请求
let csr = forge.pki.createCertificationRequest();
csr.publicKey = KEYPAIR.publicKey;
csr.setSubject(subject);
csr.sign(KEYPAIR.privateKey, forge.md.sha256.create());
csr.publicKey = KEYPAIR.publicKey;
csr.setSubject(subject);
csr.sign(KEYPAIR.privateKey, forge.md.sha256.create());
// 签发证书
let cert = forge.pki.createCertificate();
// 签发证书
let cert = forge.pki.createCertificate();
let md5 = forge.md.md5.create();
md5.update(domain);
cert.serialNumber = md5.digest().toHex();
let md5 = forge.md.md5.create();
md5.update(domain);
cert.serialNumber = md5.digest().toHex();
let notBefore = new Date();
notBefore.setFullYear(notBefore.getFullYear() - 1);
cert.validity.notBefore = notBefore;
let notBefore = new Date();
notBefore.setFullYear(notBefore.getFullYear() - 1);
cert.validity.notBefore = notBefore;
let notAfter = new Date();
notAfter.setFullYear(notAfter.getFullYear() + 1);
cert.validity.notAfter = notAfter;
let notAfter = new Date();
notAfter.setFullYear(notAfter.getFullYear() + 1);
cert.validity.notAfter = notAfter;
cert.setSubject(csr.subject.attributes);
cert.setIssuer(CACERTOBJ.subject.attributes);
cert.setSubject(csr.subject.attributes);
cert.setIssuer(CACERTOBJ.subject.attributes);
// Chrome 58后需要证书中包含subjectAltName(SAN)等信息
cert.setExtensions([
{
name: "basicConstraints",
cA: false
},
{
name: "keyUsage",
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true
},
{
name: "subjectKeyIdentifier",
value: "hash"
},
{
name: "authorityKeyIdentifier",
keyid: "always",
issuer: "always"
},
{
name: "subjectAltName",
altNames: [
{
type: 2,
value: domain
}
]
}
]);
// Chrome 58后需要证书中包含subjectAltName(SAN)等信息
cert.setExtensions([
{
name: "basicConstraints",
cA: false
},
{
name: "keyUsage",
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true
},
{
name: "subjectKeyIdentifier",
value: "hash"
},
{
name: "authorityKeyIdentifier",
keyid: "always",
issuer: "always"
},
{
name: "subjectAltName",
altNames: [
{
type: 2,
value: domain
}
]
}
]);
cert.publicKey = csr.publicKey;
cert.sign(CAKEYOBJ, forge.md.sha256.create());
return {
key: forge.pki.privateKeyToPem(KEYPAIR.privateKey),
cert: forge.pki.certificateToPem(cert)
};
};
cert.publicKey = csr.publicKey;
cert.sign(CAKEYOBJ, forge.md.sha256.create());
cb(null, forge.pki.privateKeyToPem(KEYPAIR.privateKey), forge.pki.certificateToPem(cert));
}
module.exports = {
root: CACERT,
path: CACERTPATH,
sign: function(domain, cb) {
const rst = signSync(domain);
cb(null, rst.key, rst.cert);
},
signSync: signSync
};
{
"name": "https-cert",
"version": "1.2.3",
"version": "1.2.4",
"description": "https-cert",

@@ -5,0 +5,0 @@ "main": "index.js",

var httpsCert = require("../index");
httpsCert.sign("g.alicdn.com", function (err, key, cert) {
console.info(key, cert)
});
});
var rst = httpsCert.signSync("g.alicdn.com");
console.info(rst.key, rst.cert);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc