Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// } TimestampedEntry;
this.timestamp = new Date(utilFromBase(new Uint8Array(stream.getBlock(8)), 8));
this.entryType = stream.getUint16();
switch(this.entryType)
{
case LogEntryType.constants("x509_entry"):
{
const certificateLength = stream.getUint24();
const asn1 = asn1js.fromBER((new Uint8Array(stream.getBlock(certificateLength))).buffer.slice(0));
if(asn1.offset === (-1))
throw new Error("Object's stream was not correct for TimestampedEntry");
this.signedEntry = new Certificate({ schema: asn1.result });
}
break;
case LogEntryType.constants("precert_entry"):
this.signedEntry = new PreCert({ stream });
break;
default:
throw new Error("Object's stream was not correct for TimestampedEntry");
}
const extensionsLength = stream.getUint16();
if(extensionsLength)
this.extensions = (new Uint8Array(stream.getBlock(extensionsLength))).buffer.slice(0);
}
//**********************************************************************************
function CheckSSL() {
if (fs.existsSync(APP_SSL_CERT) && fs.existsSync(APP_SSL_KEY)) {
const sslCert = fs.readFileSync(APP_SSL_CERT, "utf8").replace(/-{5}[\w\s]+-{5}/ig, "").replace(/\r/g, "").replace(/\n/g, "");
// Parse cert
const asn1 = asn1js.fromBER(new Uint8Array(Buffer.from(sslCert, "base64")).buffer);
const cert = new pkijs.Certificate({ schema: asn1.result });
// Check date
if (cert.notAfter.value < new Date()) {
winston.info(`SSL certificate is expired`);
return false;
}
return true;
}
winston.info(`SSL certificate is not found`);
return false;
}
if(asn1.offset === (-1))
throw new Error("Object's stream was not correct for MerkleTreeLeaf extra_data");
const preCertificate = new Certificate({ schema: asn1.result });
//endregion
//region Get information about "precertificate_chain" array
const preCertificateChain = [];
for(const preCertificateChainElement of entry.extra_data.precertificate_chain)
{
const asn1 = asn1js.fromBER(preCertificateChainElement);
if(asn1.offset === (-1))
throw new Error("Object's stream was not correct for MerkleTreeLeaf extra_data");
preCertificateChain.push(new Certificate({ schema: asn1.result }));
}
//endregion
extraData = {
pre_certificate: preCertificate,
precertificate_chain: preCertificateChain
};
}
break;
default:
}
result.push({
leaf: entry.leaf,
extra_data: extraData
});
protected LoadRaw(rawData: BufferSource) {
this.raw = new Uint8Array(rawData as ArrayBuffer);
const asn1 = Asn1Js.fromBER(this.raw.buffer);
this.simpl = new Certificate({ schema: asn1.result });
}
//#endregion
dataView[5] = 0x05;
let cmsSignedSimpl;
const signatureTimeStamp = new SignatureTimeStamp();
const cadesCTimeStamp = new CAdESCTimestamp();
const completeCertificateReferences = new CompleteCertificateReferences();
const completeRevocationReferences = new CompleteRevocationReferences();
const ocspRequest = new OCSPRequest();
let ocspResponse;
let asn1 = asn1js.fromBER(stringToArrayBuffer(atob(User10cert)));
const certSimpl = new Certificate({ schema: asn1.result });
asn1 = asn1js.fromBER(stringToArrayBuffer(atob(CAcert)));
const caCertSimpl = new Certificate({ schema: asn1.result });
//endregion
//region Get a "crypto" extension
const crypto = getCrypto();
if(typeof crypto === "undefined")
return Promise.reject("No WebCrypto extension found");
//endregion
sequence = sequence.then(() => certSimpl.getPublicKey());
sequence = sequence.then(result =>
{
const dataView = new Uint8Array(dataBuffer);
dataView[0] = 0x00;
dataView[1] = 0x01;
dataView[2] = 0x02;
dataView[3] = 0x03;
dataView[4] = 0x04;
dataView[5] = 0x05;
let cmsSignedSimpl;
const ocspRequest = new OCSPRequest();
const aTSHashIndex = new ATSHashIndex();
let asn1 = asn1js.fromBER(stringToArrayBuffer(atob(User10cert)));
const certSimpl = new Certificate({ schema: asn1.result });
asn1 = asn1js.fromBER(stringToArrayBuffer(atob(CAcert)));
const caCertSimpl = new Certificate({ schema: asn1.result });
//endregion
//region Get a "crypto" extension
const crypto = getCrypto();
if(typeof crypto === "undefined")
return Promise.reject("No WebCrypto extension found");
//endregion
sequence = sequence.then(() => certSimpl.getPublicKey());
sequence = sequence.then(result =>
{
userPublicKey = result;
get certificate()
{
return (new Certificate({
schema: new asn1js.Sequence({
value: [
this.tbsCertificate,
(new AlgorithmIdentifier({
algorithmId: "1.2.840.113549.1.1.11",
algorithmParams: new asn1js.Null()
})).toSchema(),
new asn1js.BitString({
valueHex: new ArrayBuffer(2),
unusedBits: 0
})
]
})
}));
}
//**********************************************************************************