Skip to content
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

proposal: crypto/x509/pkix: add String() method to type Name #21615

Closed
stub42 opened this issue Aug 25, 2017 · 5 comments
Closed

proposal: crypto/x509/pkix: add String() method to type Name #21615

stub42 opened this issue Aug 25, 2017 · 5 comments

Comments

@stub42
Copy link

stub42 commented Aug 25, 2017

Please answer these questions before submitting your issue. Thanks!

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

1.9

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?

Attempt to render a pkix.Name to a string (crypto/x509/pkix)

What did you expect to see?

pkix.Name implementing the fmt.Stringer interface. The String() method would return the standard format DN string with the common fields rendered correctly (C=AU,O=CompanyOrg,CN=fred), and extra fields rendered as best they can (probably oid=val)

What did you see instead?

No String() method on pkix.Name. In addition, the oid -> name mappings are not exported, so these need to be duplicated in order to render the individual AttributeTypeAndValue components.

https://stackoverflow.com/questions/39125873/golang-subject-dn-from-x509-cert is one such implementation.

@stub42 stub42 changed the title No help rendering x509 certificate subject to DN string crypto/x509: No help rendering x509 certificate subject to DN string Aug 25, 2017
@odeke-em odeke-em changed the title crypto/x509: No help rendering x509 certificate subject to DN string proposal: crypto/x509/pkix: add String() method to type Name Aug 25, 2017
@gopherbot gopherbot added this to the Proposal milestone Aug 25, 2017
@odeke-em
Copy link
Member

Thank you @stub42 for the issue, I've retitled it a little as a proposal(since it's a feature request that needs a judgement call) and I'll page @agl and other crypto folks.

Also, in case you'd like @stub42, please feel free to submit a CL prototyping this change, it might help expedite and make it easier to review the proposal.

@rsc
Copy link
Contributor

rsc commented Aug 28, 2017

Thoughts, @agl or @FiloSottile?

@szank
Copy link

szank commented Aug 28, 2017

Just to add my 2 cents: There is RFC2253 that could be used as the basis for the Stringer implementation. Some third party services cough*mongoDB <=3.2*cough require this form.

@agl
Copy link
Contributor

agl commented Aug 29, 2017

A good implementation of RFC 2253 would be reasonable here.

@gopherbot
Copy link

Change https://golang.org/cl/67270 mentions this issue: crypto/x509: add string conversion of PKIX names

@rsc rsc modified the milestones: Proposal, Go1.10 Oct 2, 2017
@golang golang locked and limited conversation to collaborators Oct 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants