Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(result =>
{
// noinspection JSCheckFunctionSignatures
asn1 = asn1js.fromBER(result);
let ocspResponse = new OCSPResponse({ schema: asn1.result });
if(("crls" in cmsSignedSimpl) === false)
cmsSignedSimpl.crls = [];
const asn1Temp = asn1js.fromBER(ocspResponse.responseBytes.response.valueBlock.valueHex);
const tempResponse = new BasicOCSPResponse({ schema: asn1Temp.result });
cmsSignedSimpl.crls.push(new OtherRevocationInfoFormat({
otherRevInfoFormat: ocspResponse.responseBytes.responseType,
otherRevInfo: tempResponse.toSchema()
}));
});
})
]
}),
thisUpdate: getUTCDate(new Date())
});
responses.push(response);
}
}
}
//endregion
}
//endregion
//region Making final OCSP response object
basicResponse = new BasicOCSPResponse({
tbsResponseData: new ResponseData({
responderID: certSimpl.subject,
producedAt: getUTCDate(new Date()),
responses: responses
}),
signatureAlgorithm: certSimpl.signatureAlgorithm,
certs: [certSimpl]
});
ocspResponse = new OCSPResponse({
responseStatus: new asn1js.Enumerated({ value: 0 }) // successful
});
//endregion
});
.then(result =>
{
// noinspection JSCheckFunctionSignatures
asn1 = asn1js.fromBER(result);
ocspResponse = new OCSPResponse({ schema: asn1.result });
if(("crls" in cmsSignedSimpl) === false)
cmsSignedSimpl.crls = [];
const asn1Temp = asn1js.fromBER(ocspResponse.responseBytes.response.valueBlock.valueHex);
const basicResponse = new BasicOCSPResponse({ schema: asn1Temp.result });
//region Append OCSP certificates into "certificates" array
if("certs" in basicResponse)
{
if(("certificates" in cmsSignedSimpl) === false)
cmsSignedSimpl.certificates = [];
for(let i = 0; i < basicResponse.certs.length; i++)
cmsSignedSimpl.certificates.push(basicResponse.certs[i]);
}
//endregion
cmsSignedSimpl.certificates.push(caCertSimpl);
});
//endregion
//region Check input parameters
if("ocspResponse" in parameters)
ocspResponse = parameters.ocspResponse; // in_window.org.pkijs.simpl.OCSP_RESPONSE
else
throw new Error("Parameter \"ocspResponse\" is mandatory for making \"OcspResponsesID\"");
//endregion
//region Fill internal fields
if("responseBytes" in ocspResponse)
{
if(ocspResponse.responseBytes.responseType === "1.3.6.1.5.5.7.48.1.1") // id-pkix-ocsp-basic
{
const asn1 = asn1js.fromBER(ocspResponse.responseBytes.response.valueBlock.valueHex);
const basicResponse = new BasicOCSPResponse({ schema: asn1.result });
if(basicResponse.tbsResponseData.responderID instanceof RelativeDistinguishedNames)
{
this.ocspResponderID = new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
tagNumber: 1 // [1]
},
value: [basicResponse.tbsResponseData.responderID.toSchema()]
});
}
else
{
this.ocspResponderID = new asn1js.Constructed({
idBlock: {
tagClass: 3, // CONTEXT-SPECIFIC
}
}
//endregion
//region Put information about all OCSP responses
if(ocspResponses.length)
{
this.ocspVals = [];
for(let i = 0; i < ocspResponses.length; i++)
{
const asn1 = asn1js.fromBER(ocspResponses[i]);
const ocspResponse = new OCSPResponse({ schema: asn1.result });
const asn1Basic = asn1js.fromBER(ocspResponse.responseBytes.response.valueBlock.valueHex);
const basicResponse = new BasicOCSPResponse({ schema: asn1Basic.result });
this.ocspVals.push(basicResponse);
}
}
//endregion
}
//**********************************************************************************