-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
pki should not alphabetically sort OUs when using the /issue/:role path #12426
Comments
\o Hello @pfjason-bbmus, This is currently unavoidable due to our reliance on Via the role issue/ endpoint, we build the bundle using the correct Subject. However, when calling When using
And decode it, you see:
From a playground example we can additionally confirm this analysis: Code: package main
import (
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
"fmt"
)
func main() {
var name pkix.Name
name.Organization = append(name.Organization, "alpha")
name.Organization = append(name.Organization, "delta")
name.Organization = append(name.Organization, "beta")
fmt.Println("Original name: " + name.String())
raw_name, _ := asn1.Marshal(name.ToRDNSequence())
fmt.Println("Base64 of name.ToRDNSequence(): " + base64.StdEncoding.EncodeToString(raw_name))
var raw_sequence pkix.RDNSequence
var round_tripped pkix.Name
asn1.Unmarshal(raw_name, &raw_sequence)
round_tripped.FillFromRDNSequence(&raw_sequence)
fmt.Println("Round-tripped name: " + round_tripped.String())
} Output:
Which when decoded matches the above sequence types. Because all OUs are within a single RDN (which iself is a ASN.1 Per RFC 5280 Section 7.1:
So clients should treat these as equivalent, regardless of OU order, given that they're in a single OU. In order to work around this in the future (where this == putting OUs in the same SET and thus convert them to many single-valued RDNs), we'd have to add support for the RawSubject field (including when signing CSRs directly), and allow the role to specify the RawSubject encoding scheme (including which elements belong in a SET together and which belong in separate SETs). That gets non-trivial as we'd (likely) have to create a replacement scheme (wherein the role specifies which values from the request it'll accept and where they'll go), or allow the request itself to specify the raw subject. Due to the risk of the latter, perhaps it is best to introduce a role parameter But if you (or anyone else) has thoughts about designing an interface over RawSubject, happy to hear them. :-) Vault reproducer for the future:
|
Here's a hot take: introduce an
I think there's precedent for this kind of two-level structure, but I'm not sure. And of course you'd need to work around golang/go#40876. I'm sure there's something I've missed, but this could tackle #10281 and parts of #4562 and #4560. |
I like this take, but I think still missing is how do we validate this. Some thoughts:
&c. I think this mostly pushes us towards something like HCL or perhaps a JSON-type rule language. We'll also need to be able to pull values off the auth method/templates like we do presently. In short, while I like this proposal, I'm not sure how the validation side should work today and that's what needs a little more thought. (n.b.: this is definitely more than a bug, so I've reassigned the labels -- in particular, this just the behavior of the Go library, so it is hard to classify it as a bug. They do provide an alternative form ( |
Describe the bug
Issue #6596 resolves sorted OUs when they come in via the CSR, but when a policy is created with multiple OUs they are also sorted, and then when using the /issue path to generate a certificate without a CSR certificates are created with OUs in alphabetical order, not in the order they were given to the policy. They appear to be written in the correct order when viewing the policy details in the web UI, but when a certificate is generated they are alphabetical.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Generated certificates should have OUs in the policy order, not alphabetical order
Environment:
vault status
): 1.8.1vault version
): Vault v1.8.1 (4b0264f)Vault server configuration file(s):
N/A
Additional context
It shouldn't matter but we're generating ec-256 and ec-521 certificates, not RSA.
The text was updated successfully, but these errors were encountered: