You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a regression after upgrading to x509-cert 0.2.1 / der 0.7.1. The attached certificate test.txt can be parsed prefectly with x509-cert 0.1 / der 0.6.1, but fails after upgrade with the following error:
I don't think it meets the criteria for 21-byte serial numbers to be allowed, which would be adding a leading zero so the resulting number is positive.
Note: Non-conforming CAs may issue certificates with serial numbers
that are negative or zero. Certificate users SHOULD be prepared to
gracefully handle such certificates.
I think we should drop the SERIAL_NUMBER_MAX_LEN check from SertificateNumber. Instead this check should be a part of certificate builder.
Activity
tarcieri commentedon Apr 4, 2023
git bisect is probably the easiest way to narrow down what change caused this.
Offhand I'm not sure what it would've been. The only major changes to decoding I can think of were related to integer/serial number handling.
lumag commentedon Apr 4, 2023
git-bisectpoints to a8a0b04 (#795)tarcieri commentedon Apr 4, 2023
Seems I guessed it then! cc @baloo
lumag commentedon Apr 4, 2023
And going patch-by-patch (ugh), 62bbe0a is the problem.
lumag commentedon Apr 4, 2023
And, I think I know the cause:
+const SERIAL_NUMBER_MAX_LEN: Length = Length::new(20);tarcieri commentedon Apr 4, 2023
Yeah, looks like a 21-byte serial number:
I don't think it meets the criteria for 21-byte serial numbers to be allowed, which would be adding a leading zero so the resulting number is positive.
lumag commentedon Apr 4, 2023
Well, quoting RFC 5280:
I think we should drop the SERIAL_NUMBER_MAX_LEN check from
SertificateNumber. Instead this check should be a part of certificate builder.lumag commentedon Apr 4, 2023
In the end, rfc2459 did not contain such requirement. So we should be liberal in what we accept.
baloo commentedon Apr 4, 2023
I thought we relaxed the check when parsing from DER (to allow any length) and enforced the 20bytes limitation on
new?Did I imagine that discussion?
tarcieri commentedon Apr 4, 2023
See lots of previous discussion on #823, #826, and #831
tarcieri commentedon Apr 4, 2023
@baloo you even quoted the exact same excerpt of RFC 5280: #823 (comment)
baloo commentedon Apr 4, 2023
Looks like it fixed parsing of negative serials, but this one is just overlength?
tarcieri commentedon Apr 4, 2023
Yeah I think you're right. And RFC5280 doesn't seem to provide specific guidance for this case.
baloo commentedon Apr 4, 2023
That was the comment I was thinking about: #826 (comment)
x509-cert: relax serialnumber parsing, allow rfc-invalid values
tarcieri commentedon Apr 4, 2023
also regardless, this seems like the wrong error, despite the name:
That error is intended for TLV framing bugs which made this somewhat confusing.
A better one might be
ErrorKind::Valuewithtag: Tag::Integer, which would at least make it clearer where the error was occurring.x509-cert: relax serialnumber parsing, allow rfc-invalid values
x509-cert: provide parsing profiles
x509-cert: provide parsing profiles
x509-cert: provide parsing profiles
tarcieri commentedon Apr 5, 2023
I improved the error in #988.
Gonna close this in favor of #984 and #987