utilitas 1995.2.82 → 1995.2.83
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/README.md +2 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/manifest.mjs +1 -1
- package/lib/ssl.mjs +12 -4
- package/package.json +1 -1
package/lib/manifest.mjs
CHANGED
package/lib/ssl.mjs
CHANGED
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
} from './storage.mjs'
|
|
11
11
|
|
|
12
12
|
import { boardcast, isPrimary, on } from './callosum.mjs';
|
|
13
|
-
import { join } from 'path';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
14
|
import { loop } from './event.mjs';
|
|
15
|
-
import http from 'http';
|
|
15
|
+
import http from 'node:http';
|
|
16
|
+
import tls from 'node:tls';
|
|
16
17
|
|
|
17
18
|
const _NEED = ['acme-client'];
|
|
18
19
|
const __keys = __(import.meta.url, '../keys');
|
|
@@ -54,9 +55,9 @@ const _getCert = async (name, force) => {
|
|
|
54
55
|
? { csr, key, cert, domain } : null;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
const getCert = async () => {
|
|
58
|
+
const getCert = async (name) => {
|
|
58
59
|
if (curCert.key && curCert.cert) { return curCert; }
|
|
59
|
-
let { key, cert } = (await _getCert(
|
|
60
|
+
let { key, cert } = (await _getCert(name, true)) || {};
|
|
60
61
|
if (!key || !cert) {
|
|
61
62
|
[key, cert] = await Promise.all([
|
|
62
63
|
readFile(join(__keys, 'private.key')),
|
|
@@ -117,6 +118,12 @@ const ensureCert = async (domain, challengeCreate, challengeRemove, options) =>
|
|
|
117
118
|
return { csr, key, cert, domain };
|
|
118
119
|
};
|
|
119
120
|
|
|
121
|
+
const httpsServerOptions = async (options) => ({
|
|
122
|
+
...await getCert(), SNICallback: async (domain, cbf) => cbf(
|
|
123
|
+
null, tls.createSecureContext(await getCert(domain))
|
|
124
|
+
), ...options || {},
|
|
125
|
+
});
|
|
126
|
+
|
|
120
127
|
const request = (domain) => async (req, res) =>
|
|
121
128
|
req.method === GET && acmeChallenge.key
|
|
122
129
|
&& acmeChallenge.url && acmeChallenge.url === req.url
|
|
@@ -160,6 +167,7 @@ export {
|
|
|
160
167
|
createCsr,
|
|
161
168
|
ensureCert,
|
|
162
169
|
getCert,
|
|
170
|
+
httpsServerOptions,
|
|
163
171
|
init,
|
|
164
172
|
isLocalhost,
|
|
165
173
|
};
|