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

connect/ca: cease including the common name field in generated certs #10424

Merged
merged 14 commits into from
Jun 25, 2021

Conversation

rboyer
Copy link
Member

@rboyer rboyer commented Jun 17, 2021

As part of this change, we ensure that the SAN extensions are marked as
critical when the subject is empty so that AWS PCA tolerates the loss of
common names well and continues to function as a Connect CA provider.

Parts of this currently hack around a bug in crypto/x509 and can be
removed after https://go-review.googlesource.com/c/go/+/329129 lands in
a Go release.

Note: the AWS PCA tests do not run automatically, but the following
passed locally for me:

ENABLE_AWS_PCA_TESTS=1 go test ./agent/connect/ca -run TestAWS

The only remaining place that we use a CommonName in certs is for CA certs themselves, since they don't get SAN fields.

@rboyer rboyer requested a review from a team June 17, 2021 20:42
@rboyer rboyer self-assigned this Jun 17, 2021
@github-actions github-actions bot added theme/certificates Related to creating, distributing, and rotating certificates in Consul theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/tls Using TLS (Transport Layer Security) or mTLS (mutual TLS) to secure communication labels Jun 17, 2021
@vercel vercel bot temporarily deployed to Preview – consul June 17, 2021 20:44 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 17, 2021 20:44 Inactive
@@ -0,0 +1,122 @@
package connect
Copy link
Member Author

Choose a reason for hiding this comment

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

This can all go away with golang/go#46810

@rboyer
Copy link
Member Author

rboyer commented Jun 17, 2021

Parts of this can be cleaned up after golang/go#46810 (or something like it) lands.

@vercel vercel bot temporarily deployed to Preview – consul June 17, 2021 20:51 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 17, 2021 20:51 Inactive
@@ -487,8 +471,12 @@ func (c *ConsulProvider) SignIntermediate(csr *x509.CertificateRequest) (string,
effectiveNow := time.Now().Add(-1 * CertificateTimeDriftBuffer)
template := x509.Certificate{
Copy link
Member Author

@rboyer rboyer Jun 17, 2021

Choose a reason for hiding this comment

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

This blob threw me until I found it.

This spot in the code accepts a CSR but does not pass that CSR off to the crypto/x509 package or anything of the sort. The incoming CSR has select fields plucked out of it to assign to the newly generated intermediate cert.

I'd done an overmatch during cleanup and stripped the Subject: csr.Subject, line from this function which super broke intermediate certs (which only put data in the Subject/CN field). For now I modified this to handle this more like how a CSR should operate and copy the various SAN fields along with the Subject and any provided ExtraExtensions as-is.

We can discuss if the CA certs themselves should be using SAN fields, too, but the CN fields for those things are less awful to construct so it's fine to keep them for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, if we're not going to use CN everywhere else, it probably makes sense to stop using it for the CA and reflect that in the TLS utilities. Is there a reason not to?

Copy link
Member Author

@rboyer rboyer Jun 18, 2021

Choose a reason for hiding this comment

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

AWS PCA requires a CN field to be populated in order to create the Root CA. From what I can tell you can't set SAN fields on the root CA.

Copy link
Contributor

@picatz picatz Jun 18, 2021

Choose a reason for hiding this comment

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

Interesting! Seems to align with that I'm finding in https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6 and https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4 where the Subject/CN is required.

It might be nice to document the reasoning for "CN only in the CA", just not sure where.

@vercel vercel bot temporarily deployed to Preview – consul June 17, 2021 20:56 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 17, 2021 20:56 Inactive
@rboyer rboyer requested a review from picatz June 17, 2021 20:58
agent/connect/x509_patch.go Outdated Show resolved Hide resolved
agent/connect/x509_patch.go Outdated Show resolved Hide resolved
@@ -487,8 +471,12 @@ func (c *ConsulProvider) SignIntermediate(csr *x509.CertificateRequest) (string,
effectiveNow := time.Now().Add(-1 * CertificateTimeDriftBuffer)
template := x509.Certificate{
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, if we're not going to use CN everywhere else, it probably makes sense to stop using it for the CA and reflect that in the TLS utilities. Is there a reason not to?

agent/connect/x509_patch.go Outdated Show resolved Hide resolved
agent/connect/x509_patch.go Outdated Show resolved Hide resolved
agent/connect/x509_patch.go Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 18, 2021 18:46 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 18, 2021 18:46 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 18, 2021 18:46 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 18, 2021 18:46 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 18, 2021 18:50 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 18, 2021 18:50 Inactive
agent/connect/testing_ca.go Outdated Show resolved Hide resolved
tlsutil/generate.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 18, 2021 19:11 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 18, 2021 19:11 Inactive
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 4, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 4, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 5, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 5, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 5, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to dclaisse/consul that referenced this pull request Oct 5, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Oct 5, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Oct 7, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Oct 10, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Oct 18, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Oct 24, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
dclaisse added a commit to criteo-forks/consul that referenced this pull request Nov 15, 2022
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Mar 31, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Apr 3, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Apr 3, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Apr 18, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request May 23, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request May 26, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mougams pushed a commit to mougams/consul that referenced this pull request Jun 7, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mougams pushed a commit to criteo-forks/consul that referenced this pull request Jun 9, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Jun 9, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Jun 9, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mougams pushed a commit to mougams/consul that referenced this pull request Jul 11, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mougams pushed a commit to mougams/consul that referenced this pull request Jul 11, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mougams pushed a commit to criteo-forks/consul that referenced this pull request Jul 11, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Dec 12, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Dec 28, 2023
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request Apr 23, 2024
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
mbrulatout pushed a commit to criteo-forks/consul that referenced this pull request May 6, 2024
hashicorp#10424 introduced a regression,
because it removed common name also for secondary CA intermediate
certificate, which used the same code path. This violates RFC 5280,
which mandates that Issuer CN must not be empty and equal to Subject CN
of subordinate certificate. Partially revert this patch to fix consul
provider, and add a test case to prevent future regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/certificates Related to creating, distributing, and rotating certificates in Consul theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/tls Using TLS (Transport Layer Security) or mTLS (mutual TLS) to secure communication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants