Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///
///
var xadesjs = require("xadesjs");
global.xadesjs = xadesjs;
var asn1js = require("asn1js");
global.asn1js = asn1js;
var request = require("sync-request");
global.request = request;
var Pkijs = require("pkijs");
global.Pkijs = Pkijs;
var WebCrypto = require("node-webcrypto-ossl");
webcrypto = new WebCrypto();
Pkijs.setEngine('OpenSSL', webcrypto, new Pkijs.CryptoEngine({
name: 'OpenSSL',
crypto: webcrypto,
subtle: webcrypto.subtle
}));
var tl_create = require("../built/tl-create");
var assert = require("assert");
var fs = require("fs");
describe("Cisco format", function () {
it("Parse incoming text for external root bundle", function () {
this.timeout(15000);
// get static file
var ciscoText = fs.readFileSync("./test/static/ios.p7b", "binary");
import * as path from "path";
import * as sudo from "sudo-prompt";
import * as winston from "winston";
// PKI
import * as asn1js from "asn1js";
const pkijs = require("pkijs");
import { SRC_DIR } from "./const";
import { crypto } from "./crypto";
const CERT_NAME = `Fortify Local CA`;
// Set PKI engine
pkijs.setEngine("OpenSSL", crypto, new pkijs.CryptoEngine({ name: "OpenSSL", crypto, subtle: crypto.subtle }));
const alg = {
name: "RSASSA-PKCS1-v1_5",
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 2048,
hash: "SHA-256",
};
const hashAlg = "SHA-256";
/**
* Creates new certificate
*
* @param keyPair Key pair for new certificate
* @param caKey Issuer's private key for cert TBS signing
* @returns
*/
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as sudo from "sudo-prompt";
import * as winston from "winston";
// PKI
import * as asn1js from "asn1js";
const pkijs = require("pkijs");
import { SRC_DIR } from "./const";
import { crypto } from "./crypto";
// Set PKI engine
pkijs.setEngine("OpenSSL", crypto, new pkijs.CryptoEngine({ name: "OpenSSL", crypto, subtle: crypto.subtle }));
const alg = {
name: "RSASSA-PKCS1-v1_5",
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 2048,
hash: "SHA-256",
};
const hashAlg = "SHA-256";
/**
* Creates new certificate
*
* @param keyPair Key pair for new certificate
* @param caKey Issuer's private key for cert TBS signing
* @returns
*/
const fetch = require("node-fetch");
const encode = require("urlencode").encode;
const assert = require("assert");
import { CryptoEngine, setEngine } from "pkijs";
// noinspection NpmUsedModulesInstalled
const WebCrypto = require("node-webcrypto-ossl");
/**
* @type {Object}
* @property subtle
*/
const webcrypto = new WebCrypto();
setEngine("ossl-engine", webcrypto, new CryptoEngine({ name: "", crypto: webcrypto, subtle: webcrypto.subtle }));
//*********************************************************************************
async function findIssuer(certificate, issuers)
{
const result = issuers.slice();
for(let i = 0; i < result.length; i++)
{
try
{
const verificationResult = await certificate.verify(result[i]);
if(verificationResult)
return result[i];
result.splice(i, 1);
}
catch(ex)
CryptoEngine,
Certificate: PkijsCertificate,
CertificateRevocationList: PkijsCertificateRevocationList,
CertificateChainValidationEngine
} = pkijs;
const {
printHex,
isPem,
pemToBase64,
coerceToArrayBuffer,
ab2str
} = require("./utils");
// install crypto engine in pkijs
pkijs.setEngine("newEngine", webcrypto, new CryptoEngine({
name: "",
crypto: webcrypto,
subtle: webcrypto.subtle
}));
class Certificate {
constructor(cert) {
if (isPem(cert)) {
cert = pemToBase64(cert);
}
cert = coerceToArrayBuffer(cert, "certificate");
if (cert.byteLength === 0) {
throw new Error("cert was empty (0 bytes)");
}
public static setEngine(name: string, crypto: Crypto): void {
engineCrypto = {
getRandomValues: crypto.getRandomValues.bind(crypto),
subtle: crypto.subtle,
name,
};
setEngine(name, new CryptoEngine({ name, crypto, subtle: crypto.subtle }), new CryptoEngine({ name, crypto, subtle: crypto.subtle }));
}