Skip to content

proposal: crypto/x509: flag for more lax certificate parsing #70324

Description

@chris-jansson

Proposal Details

Hello team!

I would like to propose a strict/lenient flag to be supported by the crypto/x509 library, so that certificates can be successfully parsed even if they technically violate some naming rules. Please see my use case below:


I need to load a set of X.509 certificates from a remote system into my Go application. The certs are not under my control, but as I've now learned, the Go standard crypto library won't parse them if the Subject field is illegal.

Specifically, when calling x509.ParseCertificate(), I get the following error:

x509: invalid RDNSequence: invalid attribute value: invalid PrintableString

I get this error on a couple certs, because they have an underscore character in the Subject field.

I understand that the ASN.1 PrintableString spec defines the legal characters, and these certs are in violation of that, but again, the certs are not under my control. Meanwhile, I can parse the certs successfully with openssl and Java crypto libraries. This seems overly strict of Go, as developers often work with certs they didn't create.

I also tried to find some third party Go crypto libraries that were more lenient, but I didn't have much luck. The only choice I seem to have is to copy/paste the standard library's parser code into my application, and remove the checks. I certainly don't like this idea, that could likely introduce vulnerabilities in my application, and loses the value of the trusted, vetted Go standard library.

Can this strictness please be re-evaluated? Thanks!

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions