What version of Go are you using (go version)?
go1.7.4, go1.8rc1
What operating system and processor architecture are you using (go env)?
darwin/amd64
What did you do?
When parsing a certificate with the x509.ParseCertificate() function it ignores all but the first value from attributes in the Subject (pkix.Name) struct that support multiple values.
A cert contains a Subject (pkix.Name) struct. Some of the attributes in this struct support multiple values, represented as []string{}, such as OrganizationalUnit, Locality, etc:
type Name struct {
Country, Organization, OrganizationalUnit []string
Locality, Province []string
StreetAddress, PostalCode []string
SerialNumber, CommonName string
Names []AttributeTypeAndValue
ExtraNames []AttributeTypeAndValue
}
When x509.ParseCertificate() parses a certificate that has, for example, two OrganizationalUnit (OU) attributes only the first one is parsed and set in the returned x509.Certificate
Note that x509.CreateCertificate() will correctly create certs with multiple values.
Example code and additional commentary demonstrating this issue in this gist: https://gist.github.com/joemiller/c97a52d46cae0a4b38df841db8307fc4
I can move the info from the gist into this issue if that is desirable. I don't know the golang issue etiquette.
What did you expect to see?
x509.ParseCertificate() should return an x509.Certificate containing all of the values for the fields that are of type []string{}
What did you see instead?
I only see the first value for each field.
Discovered during this work: hashicorp/vault#2251
What version of Go are you using (
go version)?go1.7.4, go1.8rc1
What operating system and processor architecture are you using (
go env)?darwin/amd64
What did you do?
When parsing a certificate with the
x509.ParseCertificate()function it ignores all but the first value from attributes in the Subject (pkix.Name) struct that support multiple values.A cert contains a
Subject(pkix.Name) struct. Some of the attributes in this struct support multiple values, represented as[]string{}, such asOrganizationalUnit,Locality, etc:When
x509.ParseCertificate()parses a certificate that has, for example, twoOrganizationalUnit(OU) attributes only the first one is parsed and set in the returnedx509.CertificateNote that
x509.CreateCertificate()will correctly create certs with multiple values.Example code and additional commentary demonstrating this issue in this gist: https://gist.github.com/joemiller/c97a52d46cae0a4b38df841db8307fc4
I can move the info from the gist into this issue if that is desirable. I don't know the golang issue etiquette.
What did you expect to see?
x509.ParseCertificate()should return anx509.Certificatecontaining all of the values for the fields that are of type[]string{}What did you see instead?
I only see the first value for each field.
Discovered during this work: hashicorp/vault#2251