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

Allow templating cluster-local AIA URIs #18199

Merged
merged 10 commits into from
Dec 5, 2022

Conversation

cipherboy
Copy link
Contributor

@cipherboy cipherboy commented Dec 1, 2022

This PR adds support for templating cluster-local and issuer-specific AIA URIs on leaf certificates. With the existing cluster-local CRL and OCSP responses, this lets correct AIA information be provided on requests serviced by PR Secondary clusters.

Notably, if the cluster-local mount path is not provided, and templating is enabled, issuance will fail.

Left to do:

  • Tests
  • Changelog entry
  • Discuss if we should replace the warning with an error if templating fails on update.
  • Is the behavior change around templating-enabled (with Issuer Ref) on root generation eliding AIA URIs OK? This occurs when issuer_ref is present in the template string but we don't yet know the issuer UUID. I don't think roots in general should really have AIA URIs, so I'm fine with that.

Comment on lines 498 to 507
response, err := respondReadIssuer(issuer)
if newName != oldName {
addWarningOnDereferencing(sc, oldName, response)
}
if issuer.AIAURIs.EnableTemplating && !b.useLegacyBundleCaStorage() {
_, err = issuer.AIAURIs.toURLEntries(sc, issuer.ID)
if err != nil {
response.AddWarning(fmt.Sprintf("issuance may fail: %v\n\nConsider setting the cluster-local address if it is not already set.", err))
}
}

Check failure

Code scanning / Semgrep Scanner

Potential Error Shadowing (regex)

Potential Error Shadowing (regex)
Comment on lines 759 to 768
response, err := respondReadIssuer(issuer)
if newName != oldName {
addWarningOnDereferencing(sc, oldName, response)
}
if issuer.AIAURIs.EnableTemplating && !b.useLegacyBundleCaStorage() {
_, err = issuer.AIAURIs.toURLEntries(sc, issuer.ID)
if err != nil {
response.AddWarning(fmt.Sprintf("issuance may fail: %v\n\nConsider setting the cluster-local address if it is not already set.", err))
}
}

Check failure

Code scanning / Semgrep Scanner

Potential Error Shadowing (regex)

Potential Error Shadowing (regex)
This adds a new configuration path, /config/cluster, which retains
cluster-local configuration. By extending /config/urls and its issuer
counterpart to include an enable_templating parameter, we can allow
operators to correctly identify the particular cluster a cert was
issued on, and tie its AIA information to this (cluster, issuer) pair
dynamically.

Notably, this does not solve all usage issues around AIA URIs: the CRL
and OCSP responder remain local, meaning that some merge capability is
required prior to passing it to other systems if they use CRL files and
must validate requests with certs from any arbitrary PR cluster.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@cipherboy cipherboy force-pushed the cipherboy-template-cluster-aia-uris branch from b9d1ae2 to 0a96cd7 Compare December 2, 2022 16:56
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
website/content/api-docs/secret/pki.mdx Outdated Show resolved Hide resolved
website/content/api-docs/secret/pki.mdx Outdated Show resolved Hide resolved
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
AnPucel pushed a commit that referenced this pull request Jan 14, 2023
* Allow templating of cluster-local AIA URIs

This adds a new configuration path, /config/cluster, which retains
cluster-local configuration. By extending /config/urls and its issuer
counterpart to include an enable_templating parameter, we can allow
operators to correctly identify the particular cluster a cert was
issued on, and tie its AIA information to this (cluster, issuer) pair
dynamically.

Notably, this does not solve all usage issues around AIA URIs: the CRL
and OCSP responder remain local, meaning that some merge capability is
required prior to passing it to other systems if they use CRL files and
must validate requests with certs from any arbitrary PR cluster.

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add documentation about templated AIAs

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add changelog entry

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add tests

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* AIA URIs -> AIA URLs

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* issuer.AIAURIs might be nil

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Allow non-nil response to config/urls

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Always validate URLs on config update

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Ensure URLs lack templating parameters

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Review feedback

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@cipherboy cipherboy deleted the cipherboy-template-cluster-aia-uris branch April 21, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants