-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/x509: CreateCertificateRequest cannot write extensions with critical #13739
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
Comments
This bug report is incomplete (or at least quite confusing). It needs to answer:
A test program would be great. |
i want to write a certificaterequest, which has a extension with a critical flag
i want to get a csr has attriubutes like:
but the output is :
the critical flag is lost |
the issue cloudflare/cfssl#346 fixed a read bug in go 1.6, but i want to generate a csr |
Please post a complete program, not just a snippet. I don't see why ExtraExtensions woudn't work. It's documented to include them:
What do you get when you then Parse it? Again, show a complete program please. |
hello, ExtraExtensions works, but lose the critical flag.
I want to get the csr have the Attributes
but what i get is
the critical flag is lost |
when i parse it
this output do not match what I input in the template (critical should be true,but get fasle) |
Here is a functional & much more minimal version of what you supplied above:
It outputs:
|
From the x509.go code: atvs = append(atvs, pkix.AttributeTypeAndValue{
// There is no place for the critical flag in a CSR.
Type: e.Id,
Value: e.Value,
}) Maybe CreateCertificateRequest should return an error if you're trying to set critical, rather than discard it? And maybe it should be documented. @agl? |
I all, I think I am impacted by this problem. How can I help on this issue ? |
What caught my eye here is that OpenSSL's debug output can show a CSR extension as critical. From looking at the source, they are stuffing PKIX Extension objects into CSR attributes. I don't know if I got lost in the old PKCS documents, or whether this is a case where reality diverges from the spec, but doing what OpenSSL does seems valid here. I'll upload something in a sec. |
Change https://golang.org/cl/70851 mentions this issue: |
Thanks @agl. If I understand your fix, we will be able to set the critical flag in the In my case I need to set the Critical flag on the extended key usage |
Creating a certificate with an extended key usage as critical seems to work : go version go1.9.1 darwin/amd64 https://gist.github.com/evantill/ebeb9535458c108e35207e0dbf6fe351 |
@odeke-em sure I will swith on the CL. |
@evantill You need to not include extensions in the Attributes is all. |
I found the newest code add a new function parseCSRExtension to fixed a bug that ParseCertificateRequest cannot read the certificate request with a critical flag in request extensions; but in CreateCertificateRequest, the critical flag will be lose; the reason is same as the parse bug.
The text was updated successfully, but these errors were encountered: