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
ASN.1 / X.690 has two very different standards for Boolean in BER and DER. BER says
If the boolean value is
TRUE
the octet shall have any non-zero value, as a sender's option.
(8.2)
and DER says
If the encoding represents the boolean value TRUE, its single contents octet shall have all eight bits set to one.
(11.1)
All certificate authorities I have seen generate DER-compliant values. Some tools, though, generate certificates that seem to follow BER here, instead. Here is an example PEM:
This certificate has the value 0x01 for TRUE in the critical extension BasicConstraints. asn1.go throws a syntax error on it and prevents connection to any server using this CA.
OpenSSL's x509 mode, Python, and Java all successfully evaluate this certificate. Checking source for them shows that they are following the more relaxed BER rules for booleans - anything other than a 0 is TRUE. I believe Go should be able to as well.
The text was updated successfully, but these errors were encountered:
bradfitz
changed the title
asn1.go - Requiring DER for Boolean is too strict for some certificates
encoding/asn1: requiring DER for Boolean is too strict for some certificates
Jun 5, 2015
No thanks. We've parsed millions of certificates with Go and this issue hasn't come up before. While I don't doubt that some certificates have encoding bugs, this isn't so prevalent that we should mirror the bug in Go. The fact that OpenSSL is lax is due to it's fundamental confusion between DER and BER going back many years. That's something that I'll have to remember to test when we update the certificate building in Chrome.
ASN.1 / X.690 has two very different standards for Boolean in BER and DER. BER says
Go 1.4.2 follows the DER rule (see https://github.com/golang/go/blob/master/src/encoding/asn1/asn1.go#L57) , with the additional requirement (not stated in the spec) that FALSE is 0x00.
All certificate authorities I have seen generate DER-compliant values. Some tools, though, generate certificates that seem to follow BER here, instead. Here is an example PEM:
This certificate has the value 0x01 for TRUE in the critical extension BasicConstraints. asn1.go throws a syntax error on it and prevents connection to any server using this CA.
OpenSSL's x509 mode, Python, and Java all successfully evaluate this certificate. Checking source for them shows that they are following the more relaxed BER rules for booleans - anything other than a 0 is TRUE. I believe Go should be able to as well.
The text was updated successfully, but these errors were encountered: