-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
encoding/asn1: Unmarshal rejects PrintableString containing underscore #14017
Comments
Can you include the certificate? This sounds like it's just a case where Go is being stricter about the rules. (Note: you can still run a TLS server with a certificate that doesn't parse if you wish.) |
-----BEGIN CERTIFICATE----- |
this is the load fail x509 cert please check .thanks |
@agl @ianlancetaylor I have upload the certificate.... please help me thanks |
@laybay I did some digging, and I think there is a bug in the asn1 package.
EDITED :
According to the ASN.1 spec :
The |
@laybay I have just checked how openssl handle PRINTABLESTRING. This is a CSR but certificate should be handled the same way :
As you can see if the RDN can be represented as a PRINTABLESTRING (localityName) PRINTABLESTRING is used. If the RDN contains characters forbidden in the PRINTABLESTRING, (organizationName) then T61STRING is used instead. I guess the certificate wasn't generated with openssl. |
@agl, should we accept _ in PrintableString? Seems like probably yes? What restrictions does Chrome apply to PrintableString? Thanks. |
Per discussion with @agl, this is the first time we've seen a certificate that is malformed in this particular way, so we're not going to rush into relaxing the requirements. If you can give us more context about what software (erroneously) generated that certificate and how common the problem might be, that would help us decide what to do for Go 1.7. Adam is thinking about scanning through the Certificate Transparency logs to see if there are more there. Thanks. |
I scanned 4.5M of the 12M certificates in the Certificate Transparency "pilot" log (I ran out of disk space downloading it all) and below are the counts for the invalid characters found in PRINTABLESTRING values:
That only includes public certificates but it doesn't suggest that underscore is sufficiently widely misplaced in these strings to bend the standard for. (Ampersand is used in about one in 40K certificates and might be something that we have to make an exception for in the future.) |
Also dealing with this issue: a certificate with an underscore, in my case a client certificate. Looking for advice about how I might still use this certificate without using tls.LoadX509KeyPair. |
Decode it manually, verify manually (if you wish), extract the public key and there you go. What exactly do you wan to do with it ? |
in my program,import a customer X509 digital certificate, But ,one of this get a error, and I found in
KeyBlock,Bytes has a code 130 0x82 is not printable,so get reject, but I use C program and java all can load success! Please help me if thiis is a go mistake?
Cert, err2 := x509.ParseCertificate(KeyBlock.Bytes)
28 if err2 != nil {
29 return nil, e.New(1004, err2, "ReadX509Cert x509.ParseCertificate error;")
30 }
The text was updated successfully, but these errors were encountered: