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

Autocert: support multiple roots feature #67

Open
chris-lee-lb opened this issue Nov 5, 2022 · 3 comments
Open

Autocert: support multiple roots feature #67

chris-lee-lb opened this issue Nov 5, 2022 · 3 comments
Labels
enhancement New feature or request needs triage Waiting for discussion / prioritization by team

Comments

@chris-lee-lb
Copy link

What would you like to be added

Need a way to also keep sync the latest root bundles from step-ca server. A simple idea is that maybe we can use step ca new --exec to execute step ca roots.

Why this is needed

To support step-ca support multiple roots feature.

@chris-lee-lb chris-lee-lb added enhancement New feature or request needs triage Waiting for discussion / prioritization by team labels Nov 5, 2022
@chris-lee-lb
Copy link
Author

chris-lee-lb commented Nov 5, 2022

This features may also support step-ca federation feature as #21

@chris-lee-lb
Copy link
Author

Or maybe we can make ca.certs.root_ca.crt of values.yaml can accept multiple pem files.

Currently I faced this error - CA fingerprint: error decoding /home/step/certs/root_ca.crt: contains more than one PEM encoded block.

Looks like autocert want to insert env var - STEP_FINGERPRINT when controller inject renewer sidecar, but I can not find any information that STEP_FINGERPRINT env is must for step ca renew command.

So maybe we can remove related logic for controller ?

@maraino
Copy link
Collaborator

maraino commented Nov 9, 2022

Changing the code to avoid that error and support multiple files is quite simple. This is the code that shows that message:

autocert/controller/main.go

Lines 265 to 271 in f3ba90f

// Generate CA fingerprint
crt, err := pemutil.ReadCertificate(config.GetRootCAPath())
if err != nil {
return b, errors.Wrap(err, "CA fingerprint")
}
sum := sha256.Sum256(crt.Raw)
fingerprint := strings.ToLower(hex.EncodeToString(sum[:]))

Assuming that the first certificate is the one used, to support multiple certs we will do something like this:

// Generate CA fingerprint
crts, err := pemutil.ReadCertificateBundle(config.GetRootCAPath())
if err != nil {
	return b, errors.Wrap(err, "CA fingerprint")
}
sum := sha256.Sum256(crts[0].Raw)
fingerprint := strings.ToLower(hex.EncodeToString(sum[:]))

That will solve that error message, the main problem with integrating that right now is having the time to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

No branches or pull requests

2 participants