Make the Common Name optional in CSRs

This change doesn't set it by default when adding domains, and adds a
method to explicitly set it if desired.
pull/147/head
Matthew McPherrin 2023-11-08 21:56:07 -05:00 committed by Richard Körber
parent e26f8fc572
commit 1cf53b6cf4
1 changed files with 10 additions and 5 deletions

View File

@ -78,11 +78,7 @@ public class CSRBuilder {
* Domain name to add * Domain name to add
*/ */
public void addDomain(String domain) { public void addDomain(String domain) {
var ace = toAce(requireNonNull(domain)); namelist.add(toAce(requireNonNull(domain)));
if (namelist.isEmpty()) {
namebuilder.addRDN(BCStyle.CN, ace);
}
namelist.add(ace);
} }
/** /**
@ -222,6 +218,15 @@ public class CSRBuilder {
namebuilder.addRDN(oid, requireNonNull(value, "attribute value must not be null")); namebuilder.addRDN(oid, requireNonNull(value, "attribute value must not be null"));
} }
/**
* Sets the common name
* <p>
* Note that it is at the discretion of the ACME server to accept this parameter.
*/
public void setCommonName(String cn) {
namebuilder.addRDN(BCStyle.CN, toAce(requireNonNull(cn)));
}
/** /**
* Sets the organization. * Sets the organization.
* <p> * <p>