本文整理汇总了TypeScript中node-forge.pki.certificationRequestFromPem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript pki.certificationRequestFromPem方法的具体用法?TypeScript pki.certificationRequestFromPem怎么用?TypeScript pki.certificationRequestFromPem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-forge.pki
的用法示例。
在下文中一共展示了pki.certificationRequestFromPem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fingerprint
fingerprint(hash: "sha1" | "sha256" | "sha384" | "sha512" | "md5" = "sha1"): string {
let md: any;
const forgeCSR = forge.pki.certificationRequestFromPem(this._pem, true, true);
switch (hash) {
case "sha1":
md = forge.md.sha1.create();
break;
case "sha256":
md = forge.md.sha256.create();
break;
case "sha384":
md = forge.md.sha384.create();
break;
case "sha512":
md = forge.md.sha512.create();
break;
case "md5":
md = forge.md.md5.create();
break;
default:
throw new Error(`Unrecognized message digest hash algorithm: ${hash}`);
}
const result = md
.update(forge.asn1.toDer(forge.pki.certificationRequestToAsn1(forgeCSR)).getBytes())
.digest()
.toHex();
return result;
}
示例2: constructor
constructor(arg: string | ICSR) {
if (isICSR(arg)) {
this._publicKeyPEM = arg.publicKeyPEM;
this._numBits = arg.numBits;
this._pem = arg.pem;
this._subject = arg.subject;
this._v3Extensions = arg.v3Extensions;
this._hash = arg.hash;
this._challengePassword = arg.challengePassword;
this._unstructuredName = arg.unstructuredName;
} else if (typeof arg === "string") {
let forgeCSR: any;
try {
forgeCSR = forge.pki.certificationRequestFromPem(arg, true, true);
} catch (error) {
throw new Error(`Could not construct CSR from given pem string "${arg}"${"\n"
}issue: ${error.message}`);
}
this._publicKeyPEM = forge.pki.publicKeyToPem(forgeCSR.publicKey);
this._numBits = forgeCSR.publicKey.n.bitLength();
this._pem = arg;
this._subject = DistinguishedName.forgeCSROrCertToIDN(forgeCSR, "subject");
this._v3Extensions = forgeCSROrCertToV3ExtensionArray(forgeCSR);
this._hash = forgeCSR.md.algorithm;
if (forgeCSR.getAttribute({name: "challengePassword"})) {
this._challengePassword
= forgeCSR.getAttribute({name: "challengePassword"}).value;
} else {
this._challengePassword = null;
}
if (forgeCSR.getAttribute({name: "unstructuredName"})) {
this._unstructuredName = forgeCSR.getAttribute({name: "unstructuredName"}).value;
} else {
this._unstructuredName = null;
}
} else {
throw new Error(`The CSR constructor argument "${arg}" is not acceptable`);
}
}