-
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: PrintableString does not match the standard #10416
Comments
/cc @agl |
Based on the code that your referenced[1], the lines
Handle the characters ' ( ) + , - . / as required I believe. Can you give an example of a certificate that can't be parsed because of this? |
Maybe I have the root cause wrong. Here is a certificate and key, and an example program to demonstrate: package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
)
func main() {
certBuf, err := ioutil.ReadFile("bug-cert.pem")
if err != nil {
fmt.Printf("%v", err)
return
}
keyBuf, err := ioutil.ReadFile("bug-key.pem")
if err != nil {
fmt.Printf("%v", err)
return
}
cert, err := tls.X509KeyPair(certBuf, keyBuf)
if err != nil {
fmt.Printf("%v", err)
return
}
fmt.Printf("Block %v", cert)
} bug-cert.pem contains:
and bug-key.pem contains:
|
That certificate contains an underscore in a PrintableString, which is, indeed, invalid, no? https://en.wikipedia.org/wiki/PrintableString |
Oh for heavens sake. I'm an idiot. Sorry to bother you all with this. |
At the moment, encoding/asn1.isPrintable (http://golang.org/src/encoding/asn1/asn1.go#L324) is missing several characters from those described for PrintableString in section 5.11 of http://luca.ntop.org/Teaching/Appunti/asn1.html, to wit the characters in the string "('+,-."
This is a critical issue because it means that crypto/x509, which does depends on encoding/asn1, cannot load a lot of certificates.
The text was updated successfully, but these errors were encountered: