Skip to content

Commit

Permalink
Discourage use of cert subject common name, examples and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nmorsman committed May 22, 2024
1 parent fd0d13e commit 12f8096
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 21 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ const privateRsaKey = await acme.crypto.createPrivateRsaKey();
const privateEcdsaKey = await acme.crypto.createPrivateEcdsaKey();

const [certificateKey, certificateCsr] = await acme.crypto.createCsr({
commonName: '*.example.com',
altNames: ['example.com'],
altNames: ['example.com', '*.example.com'],
});
```

Expand Down
3 changes: 1 addition & 2 deletions examples/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ module.exports = async () => {

/* Finalize order */
const [key, csr] = await acme.crypto.createCsr({
commonName: '*.example.com',
altNames: ['example.com'],
altNames: ['example.com', '*.example.com'],
});

const finalized = await client.finalizeOrder(order, csr);
Expand Down
2 changes: 1 addition & 1 deletion examples/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = async () => {

/* Create CSR */
const [key, csr] = await acme.crypto.createCsr({
commonName: 'example.com',
altNames: ['example.com'],
});

/* Certificate */
Expand Down
3 changes: 1 addition & 2 deletions examples/dns-01/dns-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ function log(m) {

log(`Creating CSR for ${WILDCARD_DOMAIN}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: WILDCARD_DOMAIN,
altNames: [`*.${WILDCARD_DOMAIN}`],
altNames: [WILDCARD_DOMAIN, `*.${WILDCARD_DOMAIN}`],
});

log(`Ordering certificate for ${WILDCARD_DOMAIN}`);
Expand Down
2 changes: 1 addition & 1 deletion examples/http-01/http-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
/* Create CSR */
log(`Creating CSR for ${servername}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: servername,
altNames: [servername],
});

/* Order certificate */
Expand Down
2 changes: 1 addition & 1 deletion examples/tls-alpn-01/tls-alpn-01.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function getCertOnDemand(client, servername, attempt = 0) {
/* Create CSR */
log(`Creating CSR for ${servername}`);
const [key, csr] = await acme.crypto.createCsr({
commonName: servername,
altNames: [servername],
});

/* Order certificate */
Expand Down
4 changes: 2 additions & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class AcmeClient {
* @example Order a certificate using auto mode
* ```js
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* });
*
* const certificate = await client.auto({
Expand All @@ -685,7 +685,7 @@ class AcmeClient {
* @example Order a certificate using auto mode with preferred chain
* ```js
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* });
*
* const certificate = await client.auto({
Expand Down
7 changes: 4 additions & 3 deletions src/crypto/forge.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,12 @@ function formatCsrAltNames(altNames) {
* @example Create a Certificate Signing Request
* ```js
* const [certificateKey, certificateRequest] = await acme.forge.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* });
* ```
*
* @example Certificate Signing Request with both common and alternative names
* > *Warning*: Certificate subject common name has been [deprecated](https://letsencrypt.org/docs/glossary/#def-CN) and its use is [discouraged](https://cabforum.org/uploads/BRv1.2.3.pdf).
* ```js
* const [certificateKey, certificateRequest] = await acme.forge.createCsr({
* keySize: 4096,
Expand All @@ -358,7 +359,7 @@ function formatCsrAltNames(altNames) {
* @example Certificate Signing Request with additional information
* ```js
* const [certificateKey, certificateRequest] = await acme.forge.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* country: 'US',
* state: 'California',
* locality: 'Los Angeles',
Expand All @@ -373,7 +374,7 @@ function formatCsrAltNames(altNames) {
* const certificateKey = await acme.forge.createPrivateKey();
*
* const [, certificateRequest] = await acme.forge.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* }, certificateKey);
*/

Expand Down
7 changes: 4 additions & 3 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,12 @@ function createSubjectAltNameExtension(altNames) {
* @example Create a Certificate Signing Request
* ```js
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* });
* ```
*
* @example Certificate Signing Request with both common and alternative names
* > *Warning*: Certificate subject common name has been [deprecated](https://letsencrypt.org/docs/glossary/#def-CN) and its use is [discouraged](https://cabforum.org/uploads/BRv1.2.3.pdf).
* ```js
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
* keySize: 4096,
Expand All @@ -429,7 +430,7 @@ function createSubjectAltNameExtension(altNames) {
* @example Certificate Signing Request with additional information
* ```js
* const [certificateKey, certificateRequest] = await acme.crypto.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* country: 'US',
* state: 'California',
* locality: 'Los Angeles',
Expand All @@ -444,7 +445,7 @@ function createSubjectAltNameExtension(altNames) {
* const certificateKey = await acme.crypto.createPrivateEcdsaKey();
*
* const [, certificateRequest] = await acme.crypto.createCsr({
* commonName: 'test.example.com',
* altNames: ['test.example.com'],
* }, certificateKey);
*/

Expand Down
4 changes: 2 additions & 2 deletions test/50-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ describe('client', () => {

it('should generate certificate signing request', async () => {
[, testCsr] = await acme.crypto.createCsr({ commonName: testDomain }, await createKeyFn());
[, testCsrAlpn] = await acme.crypto.createCsr({ commonName: testDomainAlpn }, await createKeyFn());
[, testCsrWildcard] = await acme.crypto.createCsr({ commonName: testDomainWildcard }, await createKeyFn());
[, testCsrAlpn] = await acme.crypto.createCsr({ altNames: [testDomainAlpn] }, await createKeyFn());
[, testCsrWildcard] = await acme.crypto.createCsr({ altNames: [testDomainWildcard] }, await createKeyFn());
});

it('should resolve certificate issuers [ACME_CAP_ALTERNATE_CERT_ROOTS]', async function () {
Expand Down
3 changes: 1 addition & 2 deletions test/70-auto.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ describe('client.auto', () => {

it('should order wildcard certificate', async () => {
const [, csr] = await acme.crypto.createCsr({
commonName: testWildcardDomain,
altNames: [`*.${testWildcardDomain}`],
altNames: [testWildcardDomain, `*.${testWildcardDomain}`],
}, await createKeyFn());

const cert = await testClient.auto({
Expand Down

0 comments on commit 12f8096

Please sign in to comment.