-
Notifications
You must be signed in to change notification settings - Fork 263
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
[Bug]: Invalid JSON when applying template data to provisioner makes ca.json empty #994
Comments
Hi @mirex05, this is definitively a bug. Are you trying to set the template data or just a template? If it is a template, it probably should be: {
"subject": {
"country": "US",
"organization": "ACME Corp",
"organizationalUnit": "ACME Team",
"commonName": {{ toJson .Subject.CommonName }}
},
{{- if typeIs "*rsa.PublicKey" .Insecure.CR.PublicKey }}
"keyUsage": ["keyEncipherment", "digitalSignature"],
{{- else }}
"keyUsage": ["digitalSignature"],
{{- end }}
"extKeyUsage": ["serverAuth", "clientAuth"]
} The "issuer" will always be overwritten when we sign the certificate, so you don't really need it. The common name should be without quotes because you are using It doesn't make sense to use the template data without a template. The template data is information that you add in the ca.json that can be consumed by a template, for example, with this template data:
You can create a template that sets the subject like this: {
"subject": {
"country": {{ toJson .country }},
"organization": {{ toJson .organization }},
"organizationalUnit": {{ toJson .organizationalUnit }},
"commonName": {{ toJson .Subject.CommonName }}
},
{{- if typeIs "*rsa.PublicKey" .Insecure.CR.PublicKey }}
"keyUsage": ["keyEncipherment", "digitalSignature"],
{{- else }}
"keyUsage": ["digitalSignature"],
{{- end }}
"extKeyUsage": ["serverAuth", "clientAuth"]
} The |
This commit fixes a problem when the ca.json is truncated if the encoding of the configuration fails. This can happen adding a new provisioner with a bad template data. Related to smallstep/cli#994
This commit fixes a problem when the ca.json is truncated if the encoding of the configuration fails. This can happen by adding a new provisioner with bad template data. Related to smallstep/cli#994
Hi @maraino, currently it's only a lab before setting up |
This commit upgrades certificates with a fix for empty ca.json if a provisioner is added with an invalid template data. Fixes #994
Steps to Reproduce
Try to add provisioner using
step
CLI with invalid JSON template:step ca provisioner add acme --type ACME --force-cn --x509-template-data templates/acme-default.tpl --include-root
acme-default.tpl (with missed quoting at
issuer
field value):Your Environment
step
CLI Version - 0.24.4 (linux/amd64)Expected Behavior
Only error output by
step
CLI, without any modifications toca.json
.Actual Behavior
Error output by
step
CLI:error writing /etc/step-ca/.step/config/ca.json: json: error calling MarshalJSON for type json.RawMessage: invalid character '{' looking for beginning of object key string
and
ca.json
becomes empty.Additional Context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: