Skip to content

crypto/x509/pkix: Name.String() rfc2253 AttributeTypes  #41750

Description

@karlovskiy

What version of Go are you using (go version)?

1.15.2

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

linux, amd64

What did you do?

Print the issuer (or subject) dn from an x509 certificate:

cert.Issuer.String()

According to https://tools.ietf.org/html/rfc2253#section-2.3
we have this table of


                    String  X.500 AttributeType
                    ------------------------------
                    CN      commonName
                    L       localityName
                    ST      stateOrProvinceName
                    O       organizationName
                    OU      organizationalUnitName
                    C       countryName
                    STREET  streetAddress
                    DC      domainComponent
                    UID     userid

But currently in crypto/x509/pkix we have this

var attributeTypeNames = map[string]string{
	"2.5.4.6":  "C",
	"2.5.4.10": "O",
	"2.5.4.11": "OU",
	"2.5.4.3":  "CN",
	"2.5.4.5":  "SERIALNUMBER",
	"2.5.4.7":  "L",
	"2.5.4.8":  "ST",
	"2.5.4.9":  "STREET",
	"2.5.4.17": "POSTALCODE",
}

Could you please add "DC" and "UID" ?
Or maybe could we have special method to pass additional attributeTypeNames for custom converting x509name to the string.

What did you expect to see?

CN=TEST-DESK,DC=test-ca,DC=acm,DC=us

What did you see instead?

CN=TEST-DESK,0.9.2342.19200300.100.1.25=#1307746573742d6361,0.9.2342.19200300.100.1.25=#130361636d,0.9.2342.19200300.100.1.25=#13027573

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions