Closed ghost closed 2 years ago
Correct code is:
const ext = new Extension({
extnID: id_pkix_ocsp_pref_sig_algs,
extnValue: new OctetString(AsnConvert.serialize(new PreferredSignatureAlgorithms([
new AlgorithmIdentifier({ algorithm: "1.2.840.10045.4.3.2" }),
]))),
});
console.log(Buffer.from(AsnConvert.serialize(ext)).toString("hex")); // 301b06092b0601050507300108040e300c300a06082a8648ce3d040302
https://lapo.it/asn1js/#MBsGCSsGAQUFBzABCAQOMAwwCgYIKoZIzj0EAwI
SEQUENCE (2 elem)
OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.8
OCTET STRING (14 byte) 300C300A06082A8648CE3D040302
SEQUENCE (1 elem)
SEQUENCE (1 elem)
OBJECT IDENTIFIER 1.2.840.10045.4.3.2 ecdsaWithSHA256 (ANSI X9.62 ECDSA algorithm with SHA256)
An OCSP request with that extension returns 2 (internalError
), from seeing how BouncyCastle does it, the appropriate extension value seems to be missing a SEQUENCE, i.e. the one that does work is:
https://lapo.it/asn1js/#MB0GCSsGAQUFBzABCAQQMA4wDDAKBggqhkjOPQQDAg
I am not at all familiar with ASN.1 but maybe this code:
export declare class PreferredSignatureAlgorithms extends AsnArray<AlgorithmIdentifier> {
constructor(items?: AlgorithmIdentifier[]);
}
should be:
export declare class PreferredSignatureAlgorithms extends AsnArray<PreferredSignatureAlgorithm> {
constructor(items?: PreferredSignatureAlgorithm[]);
}
Or what am I doing wrong?
Thanks
There is an error in schema declaration. Preparing update
I've published @peculiar/asn1-ocsp@2.1.2
. Please try it.
const ext = new Extension({
extnID: id_pkix_ocsp_pref_sig_algs,
extnValue: new OctetString(AsnConvert.serialize(new PreferredSignatureAlgorithms([
new PreferredSignatureAlgorithm({
sigIdentifier: new AlgorithmIdentifier({ algorithm: "1.2.840.10045.4.3.2" }),
})
]))),
});
console.log(Buffer.from(AsnConvert.serialize(ext)).toString("hex"));
https://lapo.it/asn1js/#MB0GCSsGAQUFBzABCAQQMA4wDDAKBggqhkjOPQQDAg
SEQUENCE (2 elem)
OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.8
OCTET STRING (16 byte) 300E300C300A06082A8648CE3D040302
SEQUENCE (1 elem)
SEQUENCE (1 elem)
SEQUENCE (1 elem)
OBJECT IDENTIFIER 1.2.840.10045.4.3.2 ecdsaWithSHA256 (ANSI X9.62 ECDSA algorithm with SHA256)
That worked, thanks! 👍
Hi, what is the proper way to set PreferredSignatureAlgorithms to an OCSP request?
I tried the following snippet but it fails with Cannot get schema for 'Object' target