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

CSR subject attributes such as emailAddress are lost #91

Open
syncsynchalt opened this issue Sep 11, 2018 · 0 comments
Open

CSR subject attributes such as emailAddress are lost #91

syncsynchalt opened this issue Sep 11, 2018 · 0 comments

Comments

@syncsynchalt
Copy link
Contributor

syncsynchalt commented Sep 11, 2018

What I did:

  • CSR with subject /C=US/O=scep-client/OU=MDM/CN=scepclient/[email protected] is passed to the server

What happens:

  • Certificate with subject /C=US/O=scep-client/OU=MDM/CN=scepclient is returned

What should happen:

  • Certificate with subject /C=US/O=scep-client/OU=MDM/CN=scepclient/[email protected] is returned

Explanation:

In PKIMessage.SignCSR() we pass in the variable template that was generated from the CSR. I see that all the expected subject attributes (in my case C, O, OU, CN, emailAddress) are present in template.Subject.Names (the input). I inspect the output of x509.CreateCertificate and the emailAddress attribute is missing from crt.Subject.Names (only C, O, OU, CN are present, emailAddress is missing).

I tracked this down to the following code in the golang stdlib pkix.Name.ToRDNSequence():
https://golang.org/src/crypto/x509/pkix/pkix.go?s=5216:5263#L193
In this code we see that the library checks for the 9 oids it knows about, then it runs through the list of ExtraNames (there are none in our case, everything is in Names, as returned by x509.ParseCertificateRequest()). However if there were any other oids in Names than the 9 known oids (such as emailAddress), then they are lost.

To me this seems like a bug or a wart in the golang x509 library. I don't have any control over that library, so I've come up with an ugly workaround in scep instead. I haven't put a lot of effort into making it more elegant since I'm not sure it's the direction to go.

Expect a PR soon that shows my workaround. To test this issue, it may be useful to add the -email-address flag to your scepclient, see this patch: syncsynchalt@247ee76

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

No branches or pull requests

2 participants