Skip to content

ca: allow the promotion of first domain/IP to CN in profile #491

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 25 additions & 3 deletions ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ type chain struct {
}

type Profile struct {
Description string
ValidityPeriod uint64
Description string
PromoteCommonName bool
ValidityPeriod uint64
}

func (c *chain) String() string {
Expand Down Expand Up @@ -309,6 +310,22 @@ func (ca *CAImpl) newCertificate(domains []string, ips []net.IP, key crypto.Publ
IsCA: false,
}

// Check to see if the profile allows for the promotion of first domain to
// the common name. This helps emulate the Let's Encrypt "classic" profile or
// other CAs that follow similar behavior.
if prof.PromoteCommonName {
var cn string
switch {
case len(domains) > 0:
cn = domains[0]
case len(ips) > 0:
cn = ips[0].String()
Comment on lines +321 to +322
Copy link
Contributor

Choose a reason for hiding this comment

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

Off the top of my head I'm not 100% confident that using net.IP.String() will always be compliant with BRs Section 7.1.4.3, but this is Pebble so I'm not super concerned about it.

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 just not put an IP in a CN. Strategically, I want people to not rely on CNs, so I think it makes sense to omit them in Pebble

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, I agree, which is why Boulder will never put an IP in the CN. But the purpose of Pebble is to behave differently from Boulder, to ensure that ACME clients don't over-index on Boulder's specific behavior.

}
if cn != "" {
template.Subject.CommonName = cn
}
}

if ca.ocspResponderURL != "" {
template.OCSPServer = []string{ca.ocspResponderURL}
}
Expand Down Expand Up @@ -375,7 +392,12 @@ func New(log *log.Logger, db *db.MemoryStore, ocspResponderURL string, alternate
prof.ValidityPeriod = defaultValidityPeriod
}
ca.profiles[name] = &prof
ca.log.Printf("Loaded profile %q with certificate validity period of %d seconds", name, prof.ValidityPeriod)
ca.log.Printf(
"Loaded profile %q with certificate validity period of %d seconds (promote CN=%t)",
name,
prof.ValidityPeriod,
prof.PromoteCommonName,
)
}

return ca
Expand Down