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

Invert RequireCommonName into AllowNoCommonName #7139

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csr/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func VerifyCSR(ctx context.Context, csr *x509.CertificateRequest, maxNames int,
if len(names.SANs) == 0 && names.CN == "" {
return invalidNoDNS
}
if names.CN == "" && features.Enabled(features.RequireCommonName) {
if names.CN == "" && !features.Enabled(features.AllowNoCommonName) {
return invalidAllSANTooLong
}
if len(names.CN) > maxCNLength {
Expand Down
4 changes: 2 additions & 2 deletions features/featureflag_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ const (
// for the cert URL to appear.
AsyncFinalize

// RequireCommonName defaults to true, and causes the CA to fail to issue a
// certificate if there is no CommonName in the certificate. When false, the
// CA will be willing to issue certificates with no CN.
// AllowNoCommonName defaults to false, and causes the CA to fail to issue a
// certificate if we can't put a CommonName in it. When true, the
// CA will be willing to issue certificates with no CN if and only if there
// is no SAN short enough to be hoisted into the CN.
//
// According to the BRs Section 7.1.4.2.2(a), the commonName field is
// Deprecated, and its inclusion is discouraged but not (yet) prohibited.
RequireCommonName
AllowNoCommonName

// CAAAfterValidation causes the VA to only kick off CAA checks after the base
// domain control validation has completed and succeeded. This makes
Expand All @@ -100,7 +101,7 @@ var features = map[FeatureFlag]bool{
CertCheckerRequiresValidations: false,
CertCheckerRequiresCorrespondence: false,
AsyncFinalize: false,
RequireCommonName: true,
AllowNoCommonName: false,
LeaseCRLShards: false,
CAAAfterValidation: false,

Expand Down
2 changes: 1 addition & 1 deletion test/config-next/ca-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"ctLogListFile": "test/ct-test-srv/log_list.json",
"features": {
"ECDSAForAll": true,
"RequireCommonName": false
"AllowNoCommonName": true
}
},
"pa": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/ca-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"ctLogListFile": "test/ct-test-srv/log_list.json",
"features": {
"ECDSAForAll": true,
"RequireCommonName": false
"AllowNoCommonName": true
}
},
"pa": {
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/ra.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"features": {
"StoreRevokerInfo": true,
"AsyncFinalize": true,
"RequireCommonName": false
"AllowNoCommonName": true
},
"ctLogs": {
"stagger": "500ms",
Expand Down
2 changes: 1 addition & 1 deletion test/config-next/wfe2.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
},
"features": {
"ServeRenewalInfo": true,
"RequireCommonName": false
"AllowNoCommonName": true
}
},
"syslog": {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/issuance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestFirstCSRSANHoistedToCN(t *testing.T) {

// TestCommonNameSANsTooLong tests that, when the names in an order and CSR are
// too long to be hoisted into the CN, the correct behavior results (depending
// on the state of the RequireCommonName feature flag).
// on the state of the AllowNoCommonName feature flag).
func TestCommonNameSANsTooLong(t *testing.T) {
t.Parallel()

Expand All @@ -97,13 +97,13 @@ func TestCommonNameSANsTooLong(t *testing.T) {
// Issue a cert using a CSR with no CN set.
ir, err := authAndIssue(client, key, []string{san1, san2}, false)

// By default, the RequireCommonName flag is true, so issuance should have failed.
// By default, the AllowNoCommonName flag is false, so issuance should have failed.
if !strings.Contains(os.Getenv("BOULDER_CONFIG_DIR"), "test/config-next") {
test.AssertError(t, err, "issuing cert with no CN")
return
}

// But in config-next, the RequireCommonName flag is false, so issuance should
// But in config-next, the AllowNoCommonName flag is true, so issuance should
// have succeeded.
test.AssertNotError(t, err, "failed to issue test cert")
cert := ir.certs[0]
Expand Down
2 changes: 1 addition & 1 deletion wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ func (wfe *WebFrontEndImpl) NewOrder(
hasValidCNLen = true
}
}
if !hasValidCNLen && features.Enabled(features.RequireCommonName) {
if !hasValidCNLen && !features.Enabled(features.AllowNoCommonName) {
wfe.sendError(response, logEvent,
probs.RejectedIdentifier("NewOrder request did not include a SAN short enough to fit in CN"),
nil)
Expand Down