@small-tech/auto-encrypt 4.1.3 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +13 -1
- package/lib/Certificate.js +30 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -174,7 +174,19 @@ export default class AutoEncrypt {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
const
|
|
177
|
+
const shouldAddOcspMustStaple = certificate.hasOcspMustStaple || false
|
|
178
|
+
|
|
179
|
+
// During the transitionary period where Let’s Encrypt has shut down
|
|
180
|
+
// OCSP support but there are still servers out there with certificates
|
|
181
|
+
// that have OCSP stapling because their 6-month validity period isn’t
|
|
182
|
+
// over, we create the server accordingly based on whether the certificate
|
|
183
|
+
// has OCSP stapling or not so it works for both cases.
|
|
184
|
+
// TODO: OCSP support can be fully removed in August 2025. All existing
|
|
185
|
+
// servers with valid certificates will be non-OCSP at that point.
|
|
186
|
+
const serverWithoutOcspMustStaple = https.createServer(options, listener)
|
|
187
|
+
const server = shouldAddOcspMustStaple
|
|
188
|
+
? this.addOcspStapling(serverWithoutOcspMustStaple)
|
|
189
|
+
: serverWithoutOcspMustStaple
|
|
178
190
|
|
|
179
191
|
//
|
|
180
192
|
// Monkey-patch the server.
|
package/lib/Certificate.js
CHANGED
|
@@ -94,29 +94,32 @@ export default class Certificate {
|
|
|
94
94
|
#_serialNumber = null
|
|
95
95
|
#_issueDate = null
|
|
96
96
|
#_expiryDate = null
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
get
|
|
100
|
-
get
|
|
101
|
-
get
|
|
102
|
-
get
|
|
103
|
-
get
|
|
104
|
-
get
|
|
105
|
-
get
|
|
106
|
-
get
|
|
107
|
-
get
|
|
108
|
-
get
|
|
97
|
+
#_hasOcspMustStaple = null
|
|
98
|
+
|
|
99
|
+
get isProvisioned () { return this.#_pem !== null }
|
|
100
|
+
get pem () { return this.#_pem }
|
|
101
|
+
get identity () { return this.#_identity }
|
|
102
|
+
get key () { return this.#_key }
|
|
103
|
+
get serialNumber () { return this.#_serialNumber }
|
|
104
|
+
get issuer () { return this.#_issuer }
|
|
105
|
+
get subject () { return this.#_subject }
|
|
106
|
+
get alternativeNames () { return this.#_alternativeNames }
|
|
107
|
+
get issueDate () { return this.#_issueDate }
|
|
108
|
+
get expiryDate () { return this.#_expiryDate }
|
|
109
|
+
get renewalDate () { return this.#renewalDate }
|
|
110
|
+
get hasOcspMustStaple () { return this.#_hasOcspMustStaple }
|
|
109
111
|
|
|
110
112
|
set pem (certificatePem) {
|
|
111
113
|
this.#_pem = certificatePem
|
|
112
114
|
|
|
113
115
|
const details = this.parseDetails(certificatePem)
|
|
114
|
-
this.#_serialNumber
|
|
115
|
-
this.#_issuer
|
|
116
|
-
this.#_subject
|
|
117
|
-
this.#_alternativeNames
|
|
118
|
-
this.#_issueDate
|
|
119
|
-
this.#_expiryDate
|
|
116
|
+
this.#_serialNumber = details.serialNumber
|
|
117
|
+
this.#_issuer = details.issuer
|
|
118
|
+
this.#_subject = details.subject
|
|
119
|
+
this.#_alternativeNames = details.alternativeNames
|
|
120
|
+
this.#_issueDate = moment(details.issuedAt)
|
|
121
|
+
this.#_expiryDate = moment(details.expiresAt)
|
|
122
|
+
this.#_hasOcspMustStaple = details.hasOcspMustStaple
|
|
120
123
|
|
|
121
124
|
// Display the certificate with a nice border :)
|
|
122
125
|
const logMessagePrefix = ' ❨auto-encrypt❩ '
|
|
@@ -370,18 +373,26 @@ export default class Certificate {
|
|
|
370
373
|
const issuedAt = new Date(certificate.validity.notBefore.value)
|
|
371
374
|
const expiresAt = new Date(certificate.validity.notAfter.value)
|
|
372
375
|
const subject = certificate.subject.value.length > 0 ? certificate.subject.value[0][0].value.toString('utf-8').slice(2).trim() : '(No subject)'
|
|
376
|
+
let hasOcspMustStaple = false
|
|
373
377
|
|
|
374
378
|
const alternativeNames = ((certificate.extensions.filter(extension => {
|
|
375
379
|
return extension.extnID === 'subjectAlternativeName'
|
|
376
380
|
}))[0].extnValue).map(name => name.value)
|
|
377
381
|
|
|
382
|
+
certificate.extensions.forEach(extension => {
|
|
383
|
+
if (Array.isArray(extension.extnID) && extension.extnID.join('.') === '1.3.6.1.5.5.7.1.24') {
|
|
384
|
+
hasOcspMustStaple = true
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
|
|
378
388
|
return {
|
|
379
389
|
serialNumber,
|
|
380
390
|
issuer,
|
|
381
391
|
subject,
|
|
382
392
|
alternativeNames,
|
|
383
393
|
issuedAt,
|
|
384
|
-
expiresAt
|
|
394
|
+
expiresAt,
|
|
395
|
+
hasOcspMustStaple
|
|
385
396
|
}
|
|
386
397
|
}
|
|
387
398
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@small-tech/auto-encrypt",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Automatically provisions and renews Let’s Encrypt TLS certificates on Node.js https servers (including Kitten, Polka, Express.js, etc.)",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.20.0"
|