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

Support certificate policies in the pki backend #4125

Merged
merged 10 commits into from
Mar 20, 2018

Conversation

remip2
Copy link
Contributor

@remip2 remip2 commented Mar 13, 2018

Add policy_identifiers field to the pki role to generate certificate with custom certificate policies.
Add basic constraint CA:FALSE by default in certificate extensions.

…with custom certificate policies.\nAdd basic constraint CA:FALSE by default in certificate extensions.
@@ -1240,6 +1259,9 @@ func signCertificate(data *dataBundle) (*certutil.ParsedCertBundle, error) {
if certTemplate.MaxPathLen == 0 {
certTemplate.MaxPathLenZero = true
}
} else {
certTemplate.BasicConstraintsValid = true
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for this change? Also, IsCA wouldn't need to be set explicitly false, and if BasicConstraintsValid should be true in either case it should be pulled out of the if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

client/server certificates should have this constraint explicitly set. Some old tools/browser refuse to connect to web servers with a certificate without the basicConstraint CA:False

To not change the default behaviour, I updated the patch to add an option in the pki role for that.

@jefferai jefferai added this to the 0.9.6 milestone Mar 14, 2018
// addPolicyIdentifiers adds certificate policies extension
//
func addPolicyIdentifiers(data *dataBundle, certTemplate *x509.Certificate) {
if len(data.params.PolicyIdentifiers) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Can this if condition can be removed?

func addPolicyIdentifiers(data *dataBundle, certTemplate *x509.Certificate) {
for _, oidstr := range data.params.PolicyIdentifiers {
oid, err := stringToOid(oidstr)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should return an error if we can't parse an OID instead of silently swallowing the error.

Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should do that at submission time, sanity-checking the role data that was provided? It's safer to do in both places but not sure it's really necessary.

@@ -262,6 +262,16 @@ for "generate_lease".`,
Default: true,
Description: `If set to false, makes the 'common_name' field optional while generating a certificate.`,
},
"policy_identifiers": &framework.FieldSchema{
Type: framework.TypeCommaStringSlice,
Default: []string{},
Copy link
Contributor

Choose a reason for hiding this comment

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

This default value is not required.

},
"basic_constraints_valid_for_non_ca": &framework.FieldSchema{
Type: framework.TypeBool,
Default: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This default value is not required.

@jefferai jefferai added the ui label Mar 19, 2018
@jefferai
Copy link
Member

Going to merge this, will address Chris' concern separately.

@jefferai jefferai merged commit 6cd5f1d into hashicorp:master Mar 20, 2018
jefferai added a commit that referenced this pull request Mar 20, 2018
@jefferai
Copy link
Member

Thanks @remip2 !

@meirish meirish mentioned this pull request Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants