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

add new pkiCert template function #1559

Merged
merged 1 commit into from
Apr 1, 2022
Merged

add new pkiCert template function #1559

merged 1 commit into from
Apr 1, 2022

Conversation

eikenb
Copy link
Contributor

@eikenb eikenb commented Mar 30, 2022

The new pkiCert template function and its dependency. Common PKI dependency testing setup code was placed in vault_common and called in TestMain. Documentation and template tests round things out.

Most of this is pretty standard new-template-function stuff. The main differing point for this Dependency is that it is specialized to the certificate and uses the rendered template destination file as a cache for the certificate, reading it in and checking the dates to see if it is still valid. If so it reuses it, if not (or if it's not there) it fetches a new one. It tries to handle this 'cache' file as forgivingly as possible, skipping over other CA certificates and text for the PEM encoded/formatted certificate. It should skip any CA, root or intermediary/chain.

Fixes #1259

@eikenb eikenb added bug vault Related to the Vault integration labels Mar 30, 2022
@eikenb eikenb added this to the v0.29.0 milestone Mar 30, 2022
@eikenb eikenb requested a review from a team March 30, 2022 20:44
return nil, fmt.Errorf("no secret exists at %s", d.pkiPath)
}
printVaultWarnings(d, vaultSecret.Warnings)
encPEM, ok := vaultSecret.Data["certificate"].(string)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting Go-ism for the reviewer. The 'ok' here is both for the dictionary lookup and the type assertion. If the dictionary is missing the key it will be set to false and if the type assertion fails the same. Hadn't realized you could chain ok tests like that.

@wilkermichael wilkermichael self-assigned this Mar 31, 2022
dependency/vault_pki.go Outdated Show resolved Hide resolved
dependency/vault_pki.go Outdated Show resolved Hide resolved
template/template.go Outdated Show resolved Hide resolved
dependency/vault_pki_test.go Show resolved Hide resolved
dependency/vault_pki_test.go Show resolved Hide resolved
@eikenb eikenb force-pushed the pki-template-function branch 3 times, most recently from c8f2eb8 to 863b7d7 Compare April 1, 2022 00:35
The new pkiCert template function and its dependency. Common PKI
dependency testing setup code was placed in vault_common and called in
TestMain. Documentation and template tests round things out.

Most of this is pretty standard new-template-function stuff. The main
differing point for this Dependency is that it is specialized to the
certificate and uses the rendered template destination file as a cache
for the certificate, reading it in and checking the dates to see if it
is still valid. If so it reuses it, it not (or if it's not there) it
fetches a new one. It tries to handle this 'cache' file as forgivingly as
possible, skipping over other CA certificates and text for the PEM
encoded/formatted certificate. It should skip any CA, root or
intermediary/chain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug vault Related to the Vault integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

All PKI certs are regenerated on reload signal
2 participants