Skip to content

vault ca bundle support - #911

Merged
jetstack-bot merged 4 commits into
cert-manager:masterfrom
vdesjardins:vault-ca-bundle
Oct 12, 2018
Merged

jetstack-bot merged 4 commits into
cert-manager:masterfrom
vdesjardins:vault-ca-bundle

Conversation

@vdesjardins

@vdesjardins vdesjardins commented Sep 16, 2018 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Add a caBundle field to Vault Issuer.

Which issue this PR fixes:
fixes #834

Special notes for your reviewer:

Release note:

A new field *caBundle* added to the Vault Issuer configures a CA certificate used to validate the connection to the Vault Server.

@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. labels Sep 16, 2018
@jetstack-bot jetstack-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 16, 2018
@vdesjardins
vdesjardins force-pushed the vault-ca-bundle branch 2 times, most recently from 781613d to 8ff5e07 Compare September 17, 2018 01:26
@vdesjardins

Copy link
Copy Markdown
Contributor Author

/ok-to-test

@munnerz munnerz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few comments, otherwise looks good to me! We should just make sure we're very clear with docs, and also cover any invalid configurations as part of validation so we catch it early on 😄

// Vault URL path to the certificate role
Path string `json:"path"`
// CA bundle to validate Vault server certificate
CABundle string `json:"caBundle"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a []byte, inline with other examples of caBundle in Kubernetes. Users then specify it as a base64 encoded value in their YAML 😄 (we should also update the docs to mention this too)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also add some resource validation that attempts to decode this bundle and ensures it is valid?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, can you update the comment (and other doc above) to clarify the behaviour if:

  • A user specifies a https:// URL, but no caBundle
  • A user specifies a https:// URL, with a caBundle (i.e. call out that system roots are not used at all)
  • A user specifies a http:// URL, with a caBundle

key value that store the *secretId*. The optional attribute *path* specifies
where the AppRole authentication is mounted in Vault. The attribute *path* default
value is *approle*.
value is *approle*. An optional *caBundle* in PEM format can be provided to validate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: split onto new line after *approle*.

vault:
path: pki_int/sign/example-dot-com
server: https://vault
caBundle: ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of ... can we have something like <base64 encoded caBundle PEM file>

@vdesjardins
vdesjardins force-pushed the vault-ca-bundle branch 2 times, most recently from 30ba75f to 4244781 Compare September 24, 2018 01:23
@vdesjardins

Copy link
Copy Markdown
Contributor Author

@munnerz I updated the pr per your review comments. Thanks for the review! Let me know if anything else is needed to merge this.

@munnerz munnerz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks very much for addressing the review comments!

I've just got one final comment - notably that the validation code can be moved into the actual API validation package instead of in the issuer's Setup method.

Comment thread pkg/issuer/vault/setup.go Outdated
v.issuer.UpdateStatusCondition(v1alpha1.IssuerConditionReady, v1alpha1.ConditionFalse, errorVault, messageVaultCABundleInvalid)
return fmt.Errorf(messageVaultCABundleInvalid)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This validation should be as part of the actual API validation IMO, which will allow us to reject issuer resources with invalid CAs specified at the time they are created/updated (as opposed to when the controller is syncing the resource).

You should be able to copy this logic across to here, with some minor adjustments: https://github.com/jetstack/cert-manager/blob/master/pkg/apis/certmanager/validation/issuer.go#L115

Signed-off-by: Vincent Desjardins <[email protected]>
Signed-off-by: Vincent Desjardins <[email protected]>
Signed-off-by: Vincent Desjardins <[email protected]>
@vdesjardins

Copy link
Copy Markdown
Contributor Author

code updated with latest comment.

// if the Server URL is using HTTPS protocol. This parameter is ignored for
// plain HTTP protocol connection. If not set the system root certificates
// are used to validate the TLS connection.
CABundle []byte `json:"caBundle"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Small nit, and sorry for not spotting sooner.. this should have omitempty on it, else when marshalling nil values into json, it will be caBundle: null which trips up some JSON parsers

@munnerz

munnerz commented Oct 12, 2018

Copy link
Copy Markdown
Member

Thanks! 😄

/lgtm
/approve

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 12, 2018
@jetstack-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: munnerz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2018
@jetstack-bot
jetstack-bot merged commit 54d8ef7 into cert-manager:master Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cert-manager cannot communicate with Vault, if Vault is using an internal CA.

3 participants