Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing leading zero in serial number #218

Closed
jvehent opened this issue May 1, 2017 · 0 comments · Fixed by #245
Closed

Missing leading zero in serial number #218

jvehent opened this issue May 1, 2017 · 0 comments · Fixed by #245

Comments

@jvehent
Copy link
Contributor

jvehent commented May 1, 2017

We parse serial numbers of certificate into hex string stored in database. The parsing currently ignores leading zero, and should append them properly.

According to @jcjones, there should only ever be a single leading zero, as while ASN.1 permits INTEGER to do insane things, the WebPKI (because of DER-form) only lets there be one leading zero, corresponding to the first nybble of the most significant byte. In this case, the actual ASN.1 is:

02 04 07 27 7F 52

so it's cool and correct to show that leading zero. It's ASN.1-legal to encode something more like:

02 04 00 07 DE AD

but that's not the minimal form of the integer, so it is not DER-encoded, and thus shouldn't pass one of CertLint / CABLint (I forget which one).

@mozkeeler added:

Another important example here would be something like 02 03 00 F0 0F where the leading 00 indicates that this is a positive value, not negative. (Serial numbers must be positive under RFC 5280, but some CAs have issued certificates where the serial number's leading bit is set, meaning it is actually negative.)

A good rule might be to show exactly the contents of the value portion of the tag-length-value of the serial number encoding. That is, for the certificate in question, we might display "07277F52". For the example I
added, we might display "00F00F".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant