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

Cannot issue intermediates from cross-signed intermediate due to error validating chain #28749

Open
lboynton opened this issue Oct 22, 2024 · 0 comments
Labels
bug Used to indicate a potential bug reproduced This issue has been reproduced by a Vault engineer secret/pki

Comments

@lboynton
Copy link
Contributor

lboynton commented Oct 22, 2024

Describe the bug
I've followed the Build your own CA tutorial, and set up a cross-signed intermediate using a new root. In the tutorial this involves setting the manual_chain attribute on both the existing and cross-signed intermediate so that when new intermediate or leaf certs are issued, the chain includes the multiple trust paths to both roots.

The problem comes if you want to issue a new intermediate from an intermediate that has multiple trust paths. The following error occurs when attempting to sign a CSR using an intermediate with multiple trust paths:

vault write -format=json pki_int/issuer/xc-example-dot-com-intermediate/sign-intermediate \
     csr=@pki_intermediate_two.csr \
     format=pem_bundle ttl="43800h" \
     | jq -r '.data.certificate' > intermediate_two.cert.pem
Error writing data to pki_int/issuer/xc-example-dot-com-intermediate/sign-intermediate: Error making API request.

URL: PUT http://127.0.0.1:8200/v1/pki_int/issuer/xc-example-dot-com-intermediate/sign-intermediate
Code: 500. Errors:

* 1 error occurred:
	* verification of parsed bundle failed: certificate 2 of certificate chain ca trust path is incorrect ("example.com Intermediate Authority"/"example.com Intermediate Authority") (7FF8A6666B32CCD3E87669EC99D60104943D8B6D/B2C40D49346490E05B2044C8B1CD88B5B76A1168)

Reading the code that verifies the chain, it looks like it only handles a single trust path:

for i, caCert := range certPath[1:] {
if !caCert.Certificate.IsCA {
return fmt.Errorf("certificate %d of certificate chain is not a certificate authority", i+1)
}
if !bytes.Equal(certPath[i].Certificate.AuthorityKeyId, caCert.Certificate.SubjectKeyId) {
return fmt.Errorf("certificate %d of certificate chain ca trust path is incorrect (%q/%q) (%X/%X)",
i+1,
certPath[i].Certificate.Subject.CommonName, caCert.Certificate.Subject.CommonName,
certPath[i].Certificate.AuthorityKeyId, caCert.Certificate.SubjectKeyId)
}
}

To Reproduce
Steps to reproduce the behavior:

  1. Follow the build your own CA tutorial, specifically steps 1, 2, 3, 7 and 9. It's important that you set the manual_chain attribute by running:
vault patch pki_int/issuer/xc-example-dot-com-intermediate \
    manual_chain=self,"$(vault read -field=default pki_int/config/issuers)"
  1. Enable a new pki secrets engine vault secrets enable -path=pki_int_two pki
  2. Tune the secrets engine vault secrets tune -max-lease-ttl=43800h pki_int_two
  3. Generate an intermediate CSR
vault write -format=json pki_int_two/intermediate/generate/internal \                 
     common_name="example.com Intermediate Two Authority" \
     issuer_name="example-dot-com-intermediate-two" \
     | jq -r '.data.csr' > pki_intermediate_two.csr
  1. Sign the intermediate certificate
vault write -format=json pki_int/issuer/xc-example-dot-com-intermediate/sign-intermediate \
     csr=@pki_intermediate_two.csr \
     format=pem_bundle ttl="43800h" \
     | jq -r '.data.certificate' > intermediate_two.cert.pem

Expected behavior
The sign-intermediate command should sign the new intermediate.

Instead we get verification of parsed bundle failed: certificate 2 of certificate chain ca trust path is incorrect.

Environment:

  • Vault Server Version (retrieve with vault status): 1.16.11 (but also reproduced with main branch, currently 1.19.0-beta1)
  • Vault CLI Version (retrieve with vault version): 1.17.3
  • Server Operating System/Architecture: Linux/MacOS
@miagilepner miagilepner added secret/pki reproduced This issue has been reproduced by a Vault engineer bug Used to indicate a potential bug labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug reproduced This issue has been reproduced by a Vault engineer secret/pki
Projects
None yet
Development

No branches or pull requests

2 participants