Closed jefjos closed 3 years ago
const bigInteger = new asn1js.Integer({ isHexOnly: true, valueHex: <put ArrayBuffer value here> });
const stringRepresentationForBigInteger = bigInteger.toString(); // Will have loooong number here, bigger than JS can handle
Thanks @YuryStrozhevsky
I tried your suggestion, however I am getting a negative serial number
Serial Number:
(Negative)7e:78:e6:ef:a0:c0:b2:ad:40:84:9c:48:f6:ae:cc:4a
Serial numbers are supposed to be positive integers I believe - https://tools.ietf.org/html/rfc5280#section-4.1.2.2
You need to be more familiar with ASN.1 integers. If you need non-negative ASN.1 integer for this particular value just put 0x00 at the beginning.
Thanks @YuryStrozhevsky for your answer. I tried adding 0x00 in the beginning. However such a certificate cannot be decoded by OpenSSL as it gives me an illegal padding error. So then I tried adding a single byte with value 1, so that it is not considered illegal padding, and the value also turns positive. Thank you for the inputs, they have helped me a lot.
Again - you need to be more familiar with ASN.1 integers. Read any articles about "two's compliment number format".
Can I set a Bigint as serial number in certificate?
I am creating a serialNumber of 128 bits length,, but asn1.Integer takes number(64 bits) as constructor param.