本文整理匯總了TypeScript中node-forge.pki.verifyCertificateChain方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript pki.verifyCertificateChain方法的具體用法?TypeScript pki.verifyCertificateChain怎麽用?TypeScript pki.verifyCertificateChain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類node-forge.pki
的用法示例。
在下文中一共展示了pki.verifyCertificateChain方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: verifySigningChain
verifySigningChain(certChain: string | ICert[] | ICert): boolean {
let forgeCertArray: any[] = [];
if (typeof certChain === "string") {
const rPEM = /\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g;
let forgeCert: any;
let match;
while((match = rPEM.exec(certChain)) !== null) {
try {
forgeCert = forge.pki.certificateFromPem(match[0]);
} catch (error) {
throw new Error(``);
}
forgeCertArray.push(forgeCert);
}
} else if (Array.isArray(certChain)) {
for (let cert of certChain) {
if (isICert(cert)) {
forgeCertArray.push(forge.pki.certificateFromPem(cert.pem));
} else {
throw new Error(``);
}
}
} else if (isICert(certChain)) {
forgeCertArray.push(forge.pki.certificateFromPem(certChain.pem));
} else {
throw new Error(``);
}
return forge.pki.verifyCertificateChain(this._forgeCAStore, forgeCertArray, true);
}
示例2: function
{
const emptyStore = forge.pki.createCaStore();
const certificate = cert;
const pem = forge.pki.certificateToPem(certificate);
const caStore = forge.pki.createCaStore();
caStore.addCertificate(certificate);
caStore.removeCertificate(certificate);
caStore.listAllCertificates();
caStore.removeCertificate(certificate);
forge.pki.verifyCertificateChain(caStore, [certificate], (verified, depth, chain) => {
return true;
});
}
{
let md: forge.md.MessageDigest;
md = forge.md.sha256.create();
const key1: string = forge.pkcs5.pbkdf2("password", "salt", 1000, 32);
const key2: string = forge.pkcs5.pbkdf2("password", "salt", 1000, 32, md);
let key3: string;
forge.pkcs5.pbkdf2("password", "salt", 1000, 32, function(err: Error | null, dk: null | string) {
if (err === null)
key3 = dk;
else