Skip to content

Simple TLS controller - #347

Merged
openshift-merge-robot merged 4 commits into
openshift:masterfrom
squeed:tls-controller
Oct 18, 2019
Merged

Simple TLS controller#347
openshift-merge-robot merged 4 commits into
openshift:masterfrom
squeed:tls-controller

Conversation

@squeed

@squeed squeed commented Oct 10, 2019

Copy link
Copy Markdown
Contributor

This adds a PKI CRD and a controller to implement it. Given a simple request for a PKI, it creates a CA and a single certificate. It delegates this to library-go's CertificateRotationController.

A bit of ugliness is needed to duct-tape a typed and untyped controller library, but it works well enough.

This will be used for implementing TLS for OVN.

@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 10, 2019
@danwinship

Copy link
Copy Markdown
Contributor

This will be used for implementing TLS for OVN.

Why can't we use the existing certificate-y stuff?

Also, any chance this could be used for IPsec?

@squeed

squeed commented Oct 11, 2019

Copy link
Copy Markdown
Contributor Author

hey @deads2k, this uses the CertRotationController from library-go. Would you mind giving it a look-over to see that we're using it in an expected manner?

@squeed

squeed commented Oct 11, 2019

Copy link
Copy Markdown
Contributor Author

This will be used for implementing TLS for OVN.

Why can't we use the existing certificate-y stuff?

Because the existing certificate managers all rely on the network to be up. The exception to this is the kube CA / CSR endpoint itself, but I don't want to use that for two reasons. First of all, it doesn't really save us a ton of effort, because it doesn't handle rotation. Second of all, I'd rather not issue certificates that have any sort of kube API identity.

Also, any chance this could be used for IPsec?

Definitely. We may need to get a change in to library-go that allows us to set the ciphers.

Comment thread manifests/0000_70_cluster-network-operator_01_pki_crd.yaml Outdated
Comment thread pkg/controller/pki/pki_controller.go Outdated
Comment thread manifests/0000_70_cluster-network-operator_01_pki_crd.yaml
Comment thread manifests/0000_70_cluster-network-operator_01_pki_crd.yaml
Comment thread pkg/apis/network/v1/pki_types.go Outdated
Comment thread pkg/apis/network/v1/pki_types.go Outdated
// +k8s:openapi-gen=true
type PKISpec struct {
// caCert is information about the CA certificate and key.
CACert CertSpec `json:"caCert"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this information that the user provides or information that the controller fills in? If the former, what gets done with that information?

Comment thread pkg/apis/network/v1/pki_types.go Outdated
Comment thread pkg/apis/network/v1/pki_types.go Outdated
Comment thread pkg/apis/network/v1/pki_types.go Outdated
Comment thread pkg/apis/network/v1/register.go Outdated
@squeed

squeed commented Oct 15, 2019

Copy link
Copy Markdown
Contributor Author

Thanks, as always, for the excellent review, updated.

I renamed PKI to OperatorPKI. Updated the documentation extensively. I also added in kubebuilder struct -> CRD conversion.

@danwinship danwinship left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

New docs are great.
I don't really understand most of the actual certificate stuff but I'll trust you're using the library correctly...

// commonName is the value in the certificate's CN
//
// +kubebuilder:validation:MinLength=1
CommonName string `json:"commonName"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the CertSpec type still useful? Could we just put TargetCertCommonName in OperatorPKISpec?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I suspect we'll be adding more properties (e.g. validity), so I decided to keep it.


// toClientCert is a certificate "decorator" that adds ClientAuth to the
// list of ExtendedKeyUsages. This allows the generated certificate to be
// used for both client and server auth.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, yeah, you didn't answer why you were doing this. Are you going to have the client and server using the same cert? Why not just make two certificates? That seems way more sane...

@squeed squeed Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for OVN, we have to use the same cert, since the databases will be either servers or clients depending on the replication state.

Also, the internal library-go code currently only allows creating a single cert. Eventually we could improve this, but it's not necessary now.

@pecameron

Copy link
Copy Markdown
Contributor

@squeed Your comment at the top says it creates 1 cert. Are we using the same cert/ca for both sdb and ndb, or are there two of these?

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

@squeed Your comment at the top says it creates 1 cert. Are we using the same cert/ca for both sdb and ndb, or are there two of these?

Yup. The intended use case for this is OVN. We're creating a single cert for all users.

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

/retest

(aws flake)

@danwinship

Copy link
Copy Markdown
Contributor

I'm vaguely worried that there may be some cryptographic reason why it would be bad to have the client and server using the same keys, but the only discussion of that I can find is https://crypto.stackexchange.com/questions/7874/client-and-server-using-same-ssl-certificate-any-issues which suggests it's fine other than the obvious issues we don't care about.

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Establishing a mTLS channel consists of the client sending Encrypt(Server, nonce) followed by Sign(Client, challenge). If there was a way to recover the key from one Encrypt and one Sign operation, then we're in big trouble.

Note: the challenge is not actually chosen, it's a hash of the TLS protocol state. So you can't use the client cert as an oracle. Clever.

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Nice, the CVO is failing to apply the CRD:
Could not update customresourcedefinition \"operatorpkis.network.operator.openshift.io\" (369 of 445): the object is invalid, possibly due to local cluster configuration

Looking.

@danwinship

Copy link
Copy Markdown
Contributor

Oh, right, the client certificate doesn't actually play any role in establishing the encryption. (I was worrying that if both sides started with the same secrets then some of the math might "cancel out" and result in a predictable symmetric encryption key being generated.)

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Yeah, it's a good question. I suspect it might be a consideration for DH, though I don't actually think it's possible in TLS.

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

/hold
to stop the retesting

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 16, 2019
@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

hurray, kube-builder doesn't create creatable CRDs:

The CustomResourceDefinition "operatorpkis.network.operator.openshift.io" is invalid: spec.versions: Invalid value: []apiextensions.CustomResourceDefinitionVersion{apiextensions.CustomResourceDefinitionVersion{Name:"v1", Served:true, Storage:true, Schema:(*apiextensions.CustomResourceValidation)(0xc01ffd42a8), Subresources:(*apiextensions.CustomResourceSubresources)(nil), AdditionalPrinterColumns:[]apiextensions.CustomResourceColumnDefinition(nil)}}: per-version schemas may not all be set to identical values (top-level validation should be used instead)

This also updates the update-codegen plumbing to generate the CRD
directly from the type, via kubebuilder.
This uses the existing PKI implementation in library-go, wiring it up to
the OperatorPKI CRD.

Creating a OperatorPKI CR will create a CA and a single certificate.
@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

Needed to pick up the latest (unreleased) controller-tools version.

@squeed

squeed commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 16, 2019
@squeed

squeed commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

aws flake
/retest

@squeed

squeed commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

registry flake
/retest

@squeed

squeed commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

/test e2e-aws-upgrade

@danwinship

Copy link
Copy Markdown
Contributor

/lgtm

@squeed

squeed commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

/refresh

@squeed

squeed commented Oct 17, 2019

Copy link
Copy Markdown
Contributor Author

hey @danwinship looks like the event got lost - would you mind re-tagging?

@danwinship

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2019
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, squeed

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

@openshift-bot

Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot

Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot

Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
openshift-merge-robot merged commit 25bc5ea into openshift:master Oct 18, 2019
@squeed
squeed deleted the tls-controller branch October 14, 2020 16:07
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. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants