@jsenv/https-local 3.3.0 → 3.5.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/README.md +209 -206
- package/package.json +15 -32
- package/src/certificate_authority.js +7 -8
- package/src/certificate_request.js +4 -4
- package/src/hosts_file_verif.js +1 -2
- package/src/https_local_cli.mjs +116 -0
- package/src/internal/authority_file_infos.js +0 -1
- package/src/internal/hosts/parse_hosts.js +2 -3
- package/src/internal/hosts/read_hosts.js +0 -1
- package/src/internal/hosts/write_hosts.js +0 -2
- package/src/internal/hosts/write_line_hosts.js +0 -2
- package/src/internal/linux/chrome_linux.js +1 -2
- package/src/internal/linux/firefox_linux.js +1 -2
- package/src/internal/linux/linux.js +0 -1
- package/src/internal/linux/linux_trust_store.js +1 -2
- package/src/internal/linux/nss_linux.js +1 -2
- package/src/internal/mac/chrome_mac.js +1 -2
- package/src/internal/mac/firefox_mac.js +1 -2
- package/src/internal/mac/mac.js +0 -1
- package/src/internal/mac/mac_keychain.js +1 -2
- package/src/internal/mac/nss_mac.js +1 -2
- package/src/internal/nssdb_browser.js +1 -2
- package/src/internal/unsupported_platform/unsupported_platform.js +1 -1
- package/src/internal/windows/chrome_windows.js +1 -2
- package/src/internal/windows/firefox_windows.js +1 -2
- package/src/internal/windows/windows.js +0 -2
- package/src/internal/windows/windows_certutil.js +1 -2
- package/src/main.js +2 -5
package/README.md
CHANGED
|
@@ -1,77 +1,82 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
# HTTPS Local [](https://www.npmjs.com/package/@jsenv/https-local)
|
|
2
|
+
|
|
3
|
+
A programmatic way to generate locally trusted certificates for HTTPS development.
|
|
4
|
+
|
|
5
|
+
🔒 Generate certificates trusted by your operating system and browsers
|
|
6
|
+
🌐 Perfect for local HTTPS development
|
|
7
|
+
🖥️ Works on macOS, Linux, and Windows
|
|
8
|
+
⚡ Simple API for certificate management
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [HTTPS Local ](#https-local-)
|
|
13
|
+
- [Table of Contents](#table-of-contents)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [How to Use](#how-to-use)
|
|
16
|
+
- [1. Install the Root Certificate](#1-install-the-root-certificate)
|
|
17
|
+
- [2. Request Certificate for Your Server](#2-request-certificate-for-your-server)
|
|
18
|
+
- [3. Start the Server](#3-start-the-server)
|
|
19
|
+
- [Certificate Expiration](#certificate-expiration)
|
|
20
|
+
- [JavaScript API](#javascript-api)
|
|
21
|
+
- [requestCertificate](#requestcertificate)
|
|
22
|
+
- [verifyHostsFile](#verifyhostsfile)
|
|
23
|
+
- [Auto Update Hosts](#auto-update-hosts)
|
|
24
|
+
- [installCertificateAuthority](#installcertificateauthority)
|
|
25
|
+
- [Auto Trust](#auto-trust)
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
14
28
|
|
|
15
29
|
```console
|
|
16
|
-
|
|
17
|
-
|
|
30
|
+
# Install the package
|
|
31
|
+
npm install @jsenv/https-local
|
|
18
32
|
|
|
19
|
-
|
|
33
|
+
# Install and trust the root certificate
|
|
34
|
+
npx @jsenv/https-local install --trust
|
|
35
|
+
```
|
|
20
36
|
|
|
21
37
|
```js
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Re-executing this file will log the current root certificate validity and trust status.
|
|
26
|
-
* Re-executing this file 20 years later would reinstall a root certificate and re-trust it.
|
|
27
|
-
*
|
|
28
|
-
* Read more in https://github.com/jsenv/https-local#installCertificateAuthority
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
installCertificateAuthority,
|
|
33
|
-
verifyHostsFile,
|
|
34
|
-
} from "@jsenv/https-local";
|
|
38
|
+
// In your server file
|
|
39
|
+
import { createServer } from "node:https";
|
|
40
|
+
import { requestCertificate } from "@jsenv/https-local";
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const { certificate, privateKey } = requestCertificate();
|
|
43
|
+
const server = createServer(
|
|
44
|
+
{
|
|
45
|
+
cert: certificate,
|
|
46
|
+
key: privateKey,
|
|
47
|
+
},
|
|
48
|
+
(request, response) => {
|
|
49
|
+
response.end("Hello HTTPS world!");
|
|
43
50
|
},
|
|
44
|
-
|
|
51
|
+
).listen(8443, () => {
|
|
52
|
+
console.log("HTTPS server running at https://localhost:8443");
|
|
45
53
|
});
|
|
46
54
|
```
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
## How to Use
|
|
57
|
+
|
|
58
|
+
The following steps can be taken to start a local server in HTTPS:
|
|
59
|
+
|
|
60
|
+
### 1. Install the Root Certificate
|
|
49
61
|
|
|
50
62
|
```console
|
|
51
|
-
|
|
63
|
+
npx @jsenv/https-local install --trust
|
|
52
64
|
```
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
This will install a root certificate valid for 20 years.
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* If the certificate authority was not installed before executing this file, an error is thrown
|
|
61
|
-
* explaining that certificate authority must be installed first.
|
|
62
|
-
*
|
|
63
|
-
* To install the certificate authority, you can use the following command
|
|
64
|
-
*
|
|
65
|
-
* > node ./install_certificate_authority.mjs
|
|
66
|
-
*
|
|
67
|
-
* Read more in https://github.com/jsenv/https-local#requestCertificate
|
|
68
|
-
*/
|
|
68
|
+
- Re-executing this command will log the current root certificate validity and trust status
|
|
69
|
+
- Re-executing this command 20 years later would reinstall a root certificate and re-trust it
|
|
70
|
+
|
|
71
|
+
### 2. Request Certificate for Your Server
|
|
69
72
|
|
|
73
|
+
_start_dev_server.mjs_
|
|
74
|
+
|
|
75
|
+
```js
|
|
70
76
|
import { createServer } from "node:https";
|
|
71
77
|
import { requestCertificate } from "@jsenv/https-local";
|
|
72
78
|
|
|
73
79
|
const { certificate, privateKey } = requestCertificate();
|
|
74
|
-
|
|
75
80
|
const server = createServer(
|
|
76
81
|
{
|
|
77
82
|
cert: certificate,
|
|
@@ -91,31 +96,156 @@ server.listen(8080);
|
|
|
91
96
|
console.log(`Server listening at https://local.example:8080`);
|
|
92
97
|
```
|
|
93
98
|
|
|
94
|
-
|
|
99
|
+
### 3. Start the Server
|
|
95
100
|
|
|
96
101
|
```console
|
|
97
102
|
node ./start_dev_server.mjs
|
|
98
103
|
```
|
|
99
104
|
|
|
100
|
-
At this stage you have a server running in
|
|
101
|
-
The rest of this documentation goes into more details.
|
|
105
|
+
At this stage you have a server running in HTTPS.
|
|
102
106
|
|
|
103
|
-
|
|
107
|
+
## Certificate Expiration
|
|
104
108
|
|
|
105
109
|
| Certificate | Expires after | How to renew? |
|
|
106
110
|
| ----------- | ------------- | ------------------------------------ |
|
|
107
111
|
| server | 1 year | Re-run _requestCertificate_ |
|
|
108
|
-
| authority | 20
|
|
112
|
+
| authority | 20 years | Re-run _installCertificateAuthority_ |
|
|
109
113
|
|
|
110
|
-
The **server certificate** expires after one year which is the maximum duration allowed by web browsers.
|
|
114
|
+
The **server certificate** expires after one year, which is the maximum duration allowed by web browsers.
|
|
111
115
|
In the unlikely scenario where a local server is running for more than a year without interruption, restart it to re-run requestCertificate.
|
|
112
116
|
|
|
113
|
-
The **authority root certificate** expires after 20 years which is close to the maximum allowed duration.
|
|
114
|
-
In the very unlikely scenario where you are using the same machine for more than 20 years, re-execute [installCertificateAuthority](#
|
|
117
|
+
The **authority root certificate** expires after 20 years, which is close to the maximum allowed duration.
|
|
118
|
+
In the very unlikely scenario where you are using the same machine for more than 20 years, re-execute [installCertificateAuthority](#installcertificateauthority) to update certificate authority then restart your server.
|
|
119
|
+
|
|
120
|
+
## JavaScript API
|
|
121
|
+
|
|
122
|
+
### requestCertificate
|
|
123
|
+
|
|
124
|
+
The `requestCertificate` function returns a certificate and private key that can be used to start a server in HTTPS.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
import { createServer } from "node:https";
|
|
128
|
+
import { requestCertificate } from "@jsenv/https-local";
|
|
129
|
+
|
|
130
|
+
const { certificate, privateKey } = requestCertificate({
|
|
131
|
+
altNames: ["localhost", "local.example"],
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
[installCertificateAuthority](#installcertificateauthority) must be called before this function.
|
|
136
|
+
|
|
137
|
+
### verifyHostsFile
|
|
138
|
+
|
|
139
|
+
This function is not mandatory to obtain the HTTPS certificates, but it is useful to programmatically verify IP mappings that are important for your local server are present in hosts file.
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
import { verifyHostsFile } from "@jsenv/https-local";
|
|
143
|
+
|
|
144
|
+
await verifyHostsFile({
|
|
145
|
+
ipMappings: {
|
|
146
|
+
"127.0.0.1": ["localhost", "local.example"],
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Find below logs written in terminal when this function is executed:
|
|
152
|
+
|
|
153
|
+
<details>
|
|
154
|
+
<summary>Mac and Linux output</summary>
|
|
155
|
+
|
|
156
|
+
```console
|
|
157
|
+
> node ./verify_hosts.mjs
|
|
158
|
+
|
|
159
|
+
Check hosts file content...
|
|
160
|
+
⚠ 1 mapping is missing in hosts file
|
|
161
|
+
--- hosts file path ---
|
|
162
|
+
/etc/hosts
|
|
163
|
+
--- line(s) to add ---
|
|
164
|
+
127.0.0.1 localhost local.example
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
<details>
|
|
170
|
+
<summary>Windows output</summary>
|
|
171
|
+
|
|
172
|
+
```console
|
|
173
|
+
> node ./verify_hosts.mjs
|
|
174
|
+
|
|
175
|
+
Check hosts file content...
|
|
176
|
+
⚠ 1 mapping is missing in hosts file
|
|
177
|
+
--- hosts file path ---
|
|
178
|
+
C:\\Windows\\System32\\Drivers\\etc\\hosts
|
|
179
|
+
--- line(s) to add ---
|
|
180
|
+
127.0.0.1 localhost local.example
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
</details>
|
|
184
|
+
|
|
185
|
+
#### Auto Update Hosts
|
|
186
|
+
|
|
187
|
+
It's possible to update hosts file programmatically using `tryToUpdateHostsFile`:
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
import { verifyHostsFile } from "@jsenv/https-local";
|
|
191
|
+
|
|
192
|
+
await verifyHostsFile({
|
|
193
|
+
ipMappings: {
|
|
194
|
+
"127.0.0.1": ["localhost", "local.example"],
|
|
195
|
+
},
|
|
196
|
+
tryToUpdateHostsFile: true,
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>Mac and Linux output</summary>
|
|
202
|
+
|
|
203
|
+
```console
|
|
204
|
+
Check hosts file content...
|
|
205
|
+
ℹ 1 mapping is missing in hosts file
|
|
206
|
+
Adding 1 mapping(s) in hosts file...
|
|
207
|
+
❯ echo "127.0.0.1 local.example" | sudo tee -a /etc/hosts
|
|
208
|
+
Password:
|
|
209
|
+
✔ mappings added to hosts file
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
_Second execution logs_
|
|
213
|
+
|
|
214
|
+
```console
|
|
215
|
+
> node ./verify_hosts.mjs
|
|
216
|
+
|
|
217
|
+
Check hosts file content...
|
|
218
|
+
✔ all ip mappings found in hosts file
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
</details>
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary>Windows output</summary>
|
|
225
|
+
|
|
226
|
+
```console
|
|
227
|
+
Check hosts file content...
|
|
228
|
+
ℹ 1 mapping is missing in hosts file
|
|
229
|
+
Adding 1 mapping(s) in hosts file...
|
|
230
|
+
❯ (echo 127.0.0.1 local.example) >> C:\\Windows\\System32\\Drivers\\etc\\hosts
|
|
231
|
+
Password:
|
|
232
|
+
✔ mappings added to hosts file
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
_Second execution logs_
|
|
115
236
|
|
|
116
|
-
|
|
237
|
+
```console
|
|
238
|
+
> node ./verify_hosts.mjs
|
|
117
239
|
|
|
118
|
-
|
|
240
|
+
Check hosts file content...
|
|
241
|
+
✔ all ip mappings found in hosts file
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
### installCertificateAuthority
|
|
247
|
+
|
|
248
|
+
The `installCertificateAuthority` function generates a certificate authority valid for 20 years.
|
|
119
249
|
This certificate authority is needed to generate local certificates that will be trusted by the operating system and web browsers.
|
|
120
250
|
|
|
121
251
|
```js
|
|
@@ -124,12 +254,10 @@ import { installCertificateAuthority } from "@jsenv/https-local";
|
|
|
124
254
|
await installCertificateAuthority();
|
|
125
255
|
```
|
|
126
256
|
|
|
127
|
-
By default, trusting authority root certificate is a manual process. This manual process is documented in [BenMorel/dev-certificates#Import the CA in your browser](https://github.com/BenMorel/dev-certificates/tree/c10cd68945da772f31815b7a36721ddf848ff3a3#import-the-ca-in-your-browser). This process can be done programmatically as explained in [Auto
|
|
128
|
-
|
|
129
|
-
Find below logs written in terminal when this function is executed.
|
|
257
|
+
By default, trusting authority root certificate is a manual process. This manual process is documented in [BenMorel/dev-certificates#Import the CA in your browser](https://github.com/BenMorel/dev-certificates/tree/c10cd68945da772f31815b7a36721ddf848ff3a3#import-the-ca-in-your-browser). This process can be done programmatically as explained in [Auto Trust](#auto-trust).
|
|
130
258
|
|
|
131
259
|
<details>
|
|
132
|
-
<summary>
|
|
260
|
+
<summary>macOS output</summary>
|
|
133
261
|
|
|
134
262
|
```console
|
|
135
263
|
> node ./install_certificate_authority.mjs
|
|
@@ -141,7 +269,7 @@ Generating authority root certificate with a validity of 20 years...
|
|
|
141
269
|
ℹ You should add root certificate to firefox
|
|
142
270
|
```
|
|
143
271
|
|
|
144
|
-
|
|
272
|
+
_Second execution logs_
|
|
145
273
|
|
|
146
274
|
```console
|
|
147
275
|
> node ./install_certificate_authority.mjs
|
|
@@ -160,7 +288,7 @@ Check if certificate is in firefox...
|
|
|
160
288
|
</details>
|
|
161
289
|
|
|
162
290
|
<details>
|
|
163
|
-
<summary>
|
|
291
|
+
<summary>Linux output</summary>
|
|
164
292
|
|
|
165
293
|
```console
|
|
166
294
|
> node ./install_certificate_authority.mjs
|
|
@@ -173,7 +301,7 @@ Generating authority root certificate with a validity of 20 years...
|
|
|
173
301
|
ℹ You should add certificate to firefox
|
|
174
302
|
```
|
|
175
303
|
|
|
176
|
-
|
|
304
|
+
_Second execution logs_
|
|
177
305
|
|
|
178
306
|
```console
|
|
179
307
|
> node ./install_certificate_authority.mjs
|
|
@@ -194,7 +322,7 @@ Check if certificate is in firefox...
|
|
|
194
322
|
</details>
|
|
195
323
|
|
|
196
324
|
<details>
|
|
197
|
-
<summary>
|
|
325
|
+
<summary>Windows output</summary>
|
|
198
326
|
|
|
199
327
|
```console
|
|
200
328
|
> node ./install_certificate_authority.mjs
|
|
@@ -206,7 +334,7 @@ Generating authority root certificate with a validity of 20 years...
|
|
|
206
334
|
ℹ You should add certificate to firefox
|
|
207
335
|
```
|
|
208
336
|
|
|
209
|
-
|
|
337
|
+
_Second execution logs_
|
|
210
338
|
|
|
211
339
|
```console
|
|
212
340
|
> node ./install_certificate_authority.mjs
|
|
@@ -224,9 +352,9 @@ Check if certificate is trusted by firefox...
|
|
|
224
352
|
|
|
225
353
|
</details>
|
|
226
354
|
|
|
227
|
-
|
|
355
|
+
#### Auto Trust
|
|
228
356
|
|
|
229
|
-
It's possible to trust root certificate programmatically using
|
|
357
|
+
It's possible to trust root certificate programmatically using `tryToTrust`:
|
|
230
358
|
|
|
231
359
|
```js
|
|
232
360
|
import { installCertificateAuthority } from "@jsenv/https-local";
|
|
@@ -237,7 +365,7 @@ await installCertificateAuthority({
|
|
|
237
365
|
```
|
|
238
366
|
|
|
239
367
|
<details>
|
|
240
|
-
<summary>
|
|
368
|
+
<summary>macOS output</summary>
|
|
241
369
|
|
|
242
370
|
```console
|
|
243
371
|
> node ./install_certificate_authority.mjs
|
|
@@ -253,7 +381,7 @@ Adding certificate to firefox...
|
|
|
253
381
|
✔ certificate added to Firefox
|
|
254
382
|
```
|
|
255
383
|
|
|
256
|
-
|
|
384
|
+
_Second execution logs_
|
|
257
385
|
|
|
258
386
|
```console
|
|
259
387
|
> node ./install_certificate_authority.mjs
|
|
@@ -272,7 +400,7 @@ Check if certificate is in Firefox...
|
|
|
272
400
|
</details>
|
|
273
401
|
|
|
274
402
|
<details>
|
|
275
|
-
<summary>
|
|
403
|
+
<summary>Linux output</summary>
|
|
276
404
|
|
|
277
405
|
```console
|
|
278
406
|
> node ./install_certificate_authority.mjs
|
|
@@ -299,7 +427,7 @@ Adding certificate to firefox...
|
|
|
299
427
|
✔ certificate added to firefox
|
|
300
428
|
```
|
|
301
429
|
|
|
302
|
-
|
|
430
|
+
_Second execution logs_
|
|
303
431
|
|
|
304
432
|
```console
|
|
305
433
|
> node ./install_certificate_authority.mjs
|
|
@@ -320,7 +448,7 @@ Check if certificate is in firefox...
|
|
|
320
448
|
</details>
|
|
321
449
|
|
|
322
450
|
<details>
|
|
323
|
-
<summary>
|
|
451
|
+
<summary>Windows output</summary>
|
|
324
452
|
|
|
325
453
|
```console
|
|
326
454
|
> node ./install_certificate_authority.mjs
|
|
@@ -339,7 +467,7 @@ Check if certificate is trusted by firefox...
|
|
|
339
467
|
ℹ unable to detect if certificate is trusted by firefox (not implemented on windows)
|
|
340
468
|
```
|
|
341
469
|
|
|
342
|
-
|
|
470
|
+
_Second execution logs_
|
|
343
471
|
|
|
344
472
|
```console
|
|
345
473
|
> node ./install_certificate_authority.mjs
|
|
@@ -356,128 +484,3 @@ Check if certificate is trusted by firefox...
|
|
|
356
484
|
```
|
|
357
485
|
|
|
358
486
|
</details>
|
|
359
|
-
|
|
360
|
-
# requestCertificate
|
|
361
|
-
|
|
362
|
-
_requestCertificate_ function returns a certificate and private key that can be used to start a server in HTTPS.
|
|
363
|
-
|
|
364
|
-
```js
|
|
365
|
-
import { createServer } from "node:https";
|
|
366
|
-
import { requestCertificate } from "@jsenv/https-local";
|
|
367
|
-
|
|
368
|
-
const { certificate, privateKey } = requestCertificate({
|
|
369
|
-
altNames: ["localhost", "local.example"],
|
|
370
|
-
});
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
[installCertificateAuthority](#installCertificateAuthority) must be called before this function.
|
|
374
|
-
|
|
375
|
-
# verifyHostsFile
|
|
376
|
-
|
|
377
|
-
This function is not mandatory to obtain the https certificates.
|
|
378
|
-
But it is useful to programmatically verify ip mappings that are important for your local server are present in hosts file.
|
|
379
|
-
|
|
380
|
-
```js
|
|
381
|
-
import { verifyHostsFile } from "@jsenv/https-local";
|
|
382
|
-
|
|
383
|
-
await verifyHostsFile({
|
|
384
|
-
ipMappings: {
|
|
385
|
-
"127.0.0.1": ["localhost", "local.example"],
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
Find below logs written in terminal when this function is executed.
|
|
391
|
-
|
|
392
|
-
<details>
|
|
393
|
-
<summary>mac and linux</summary>
|
|
394
|
-
|
|
395
|
-
```console
|
|
396
|
-
> node ./verify_hosts.mjs
|
|
397
|
-
|
|
398
|
-
Check hosts file content...
|
|
399
|
-
⚠ 1 mapping is missing in hosts file
|
|
400
|
-
--- hosts file path ---
|
|
401
|
-
/etc/hosts
|
|
402
|
-
--- line(s) to add ---
|
|
403
|
-
127.0.0.1 localhost local.example
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
</details>
|
|
407
|
-
|
|
408
|
-
<details>
|
|
409
|
-
<summary>windows</summary>
|
|
410
|
-
|
|
411
|
-
```console
|
|
412
|
-
> node ./verify_hosts.mjs
|
|
413
|
-
|
|
414
|
-
Check hosts file content...
|
|
415
|
-
⚠ 1 mapping is missing in hosts file
|
|
416
|
-
--- hosts file path ---
|
|
417
|
-
C:\\Windows\\System32\\Drivers\\etc\\hosts
|
|
418
|
-
--- line(s) to add ---
|
|
419
|
-
127.0.0.1 localhost local.example
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
</details>
|
|
423
|
-
|
|
424
|
-
## Auto update hosts
|
|
425
|
-
|
|
426
|
-
It's possible to update hosts file programmatically using _tryToUpdateHostsFile_.
|
|
427
|
-
|
|
428
|
-
```js
|
|
429
|
-
import { verifyHostsFile } from "@jsenv/https-local";
|
|
430
|
-
|
|
431
|
-
await verifyHostsFile({
|
|
432
|
-
ipMappings: {
|
|
433
|
-
"127.0.0.1": ["localhost", "local.example"],
|
|
434
|
-
},
|
|
435
|
-
tryToUpdateHostsFile: true,
|
|
436
|
-
});
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
<details>
|
|
440
|
-
<summary>mac and linux</summary>
|
|
441
|
-
|
|
442
|
-
```console
|
|
443
|
-
Check hosts file content...
|
|
444
|
-
ℹ 1 mapping is missing in hosts file
|
|
445
|
-
Adding 1 mapping(s) in hosts file...
|
|
446
|
-
❯ echo "127.0.0.1 local.example" | sudo tee -a /etc/hosts
|
|
447
|
-
Password:
|
|
448
|
-
✔ mappings added to hosts file
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
_Second execution logs_
|
|
452
|
-
|
|
453
|
-
```console
|
|
454
|
-
> node ./verify_hosts.mjs
|
|
455
|
-
|
|
456
|
-
Check hosts file content...
|
|
457
|
-
✔ all ip mappings found in hosts file
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
</details>
|
|
461
|
-
|
|
462
|
-
<details>
|
|
463
|
-
<summary>windows</summary>
|
|
464
|
-
|
|
465
|
-
```console
|
|
466
|
-
Check hosts file content...
|
|
467
|
-
ℹ 1 mapping is missing in hosts file
|
|
468
|
-
Adding 1 mapping(s) in hosts file...
|
|
469
|
-
❯ (echo 127.0.0.1 local.example) >> C:\\Windows\\System32\\Drivers\\etc\\hosts
|
|
470
|
-
Password:
|
|
471
|
-
✔ mappings added to hosts file
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
_Second execution logs_
|
|
475
|
-
|
|
476
|
-
```console
|
|
477
|
-
> node ./verify_hosts.mjs
|
|
478
|
-
|
|
479
|
-
Check hosts file content...
|
|
480
|
-
✔ all ip mappings found in hosts file
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
</details>
|
package/package.json
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/https-local",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A programmatic way to generate locally trusted certificates",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/jsenv/
|
|
9
|
-
|
|
10
|
-
"author": {
|
|
11
|
-
"name": "dmail",
|
|
12
|
-
"email": "dmaillard06@gmail.com"
|
|
8
|
+
"url": "https://github.com/jsenv/core",
|
|
9
|
+
"directory": "packages/tooling/https-local"
|
|
13
10
|
},
|
|
14
11
|
"license": "MIT",
|
|
15
12
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
13
|
+
"node": ">=20.0.0"
|
|
17
14
|
},
|
|
15
|
+
"bin": "./src/https_local_cli.mjs",
|
|
18
16
|
"main": "./src/main.js",
|
|
19
17
|
"exports": {
|
|
20
18
|
".": {
|
|
@@ -26,25 +24,21 @@
|
|
|
26
24
|
"/src/"
|
|
27
25
|
],
|
|
28
26
|
"scripts": {
|
|
29
|
-
"eslint": "npx eslint . --ext=.js,.mjs,.cjs",
|
|
30
|
-
"test": "node ./scripts/test/test.mjs",
|
|
31
|
-
"performance": "node --expose-gc ./scripts/performance/performance.mjs --local --log",
|
|
32
|
-
"test:start-node-server": "node ./scripts/certificate/start_node_server.mjs",
|
|
33
27
|
"ca:install": "node ./scripts/certificate/install_ca.mjs",
|
|
34
28
|
"ca:log-trust": "node ./scripts/certificate/log_root_certificate_trust.mjs",
|
|
35
29
|
"ca:trust": "node ./scripts/certificate/trust_root_certificate.mjs",
|
|
36
|
-
"ca:untrust": "node ./scripts/certificate/untrust_root_certificate.mjs",
|
|
37
30
|
"ca:uninstall": "node ./scripts/certificate/uninstall_certificate_authority.mjs",
|
|
31
|
+
"ca:untrust": "node ./scripts/certificate/untrust_root_certificate.mjs",
|
|
38
32
|
"hosts:add-localhost-mappings": "node ./scripts/hosts/add_localhost_mappings.mjs",
|
|
33
|
+
"hosts:ensure-localhost-mappings": "node ./scripts/hosts/ensure_localhost_mappings.mjs",
|
|
39
34
|
"hosts:remove-localhost-mappings": "node ./scripts/hosts/remove_localhost_mappings.mjs",
|
|
40
35
|
"hosts:verify-localhost-mappings": "node ./scripts/hosts/verify_localhost_mappings.mjs",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"playwright:install": "npx playwright install-deps && npx playwright install"
|
|
36
|
+
"performance": "node --expose-gc ./scripts/performance/performance.mjs --local --log",
|
|
37
|
+
"test:start-node-server": "node ./scripts/certificate/start_node_server.mjs"
|
|
44
38
|
},
|
|
45
39
|
"dependencies": {
|
|
46
40
|
"@jsenv/filesystem": "4.15.15",
|
|
47
|
-
"@jsenv/
|
|
41
|
+
"@jsenv/humanize": "1.7.6",
|
|
48
42
|
"@jsenv/urls": "2.9.8",
|
|
49
43
|
"command-exists": "1.2.9",
|
|
50
44
|
"node-forge": "1.4.0",
|
|
@@ -52,24 +46,13 @@
|
|
|
52
46
|
"which": "6.0.1"
|
|
53
47
|
},
|
|
54
48
|
"devDependencies": {
|
|
55
|
-
"@jsenv/assert": "
|
|
56
|
-
"@jsenv/
|
|
57
|
-
"@jsenv/
|
|
58
|
-
"@jsenv/
|
|
59
|
-
"
|
|
60
|
-
"@jsenv/test": "3.7.21",
|
|
61
|
-
"eslint": "9.39.2",
|
|
62
|
-
"playwright": "1.59.1",
|
|
63
|
-
"prettier": "3.8.3",
|
|
64
|
-
"prettier-plugin-embed": "0.5.1",
|
|
65
|
-
"prettier-plugin-organize-imports": "4.3.0",
|
|
66
|
-
"prettier-plugin-pkg": "0.22.1"
|
|
49
|
+
"@jsenv/assert": "../assert",
|
|
50
|
+
"@jsenv/https-local": "./",
|
|
51
|
+
"@jsenv/performance-impact": "../performance-impact",
|
|
52
|
+
"@jsenv/test": "../../related/test",
|
|
53
|
+
"playwright": "1.59.1"
|
|
67
54
|
},
|
|
68
55
|
"publishConfig": {
|
|
69
56
|
"access": "public"
|
|
70
|
-
},
|
|
71
|
-
"volta": {
|
|
72
|
-
"node": "25.8.1",
|
|
73
|
-
"npm": "11.6.2"
|
|
74
57
|
}
|
|
75
58
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFile, removeEntry, writeFile } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE, createDetailedMessage, createLogger } from "@jsenv/
|
|
3
|
-
|
|
2
|
+
import { UNICODE, createDetailedMessage, createLogger } from "@jsenv/humanize";
|
|
4
3
|
import { getAuthorityFileInfos } from "./internal/authority_file_infos.js";
|
|
5
4
|
import { attributeDescriptionFromAttributeArray } from "./internal/certificate_data_converter.js";
|
|
6
5
|
import { createAuthorityRootCertificate } from "./internal/certificate_generator.js";
|
|
@@ -213,7 +212,7 @@ export const installCertificateAuthority = async ({
|
|
|
213
212
|
certificateValidityDurationInMs,
|
|
214
213
|
},
|
|
215
214
|
);
|
|
216
|
-
if (
|
|
215
|
+
if (rootCertificateDifferences.length) {
|
|
217
216
|
const paramNames = Object.keys(rootCertificateDifferences);
|
|
218
217
|
logger.info(
|
|
219
218
|
`${UNICODE.INFO} certificate attributes are outdated: ${paramNames}`,
|
|
@@ -327,13 +326,13 @@ export const uninstallCertificateAuthority = async ({
|
|
|
327
326
|
const rootCertificateCommonName = attributeDescriptionFromAttributeArray(
|
|
328
327
|
rootCertificateForgeObject.subject.attributes,
|
|
329
328
|
).commonName;
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
await removeCertificateFromTrustStores({
|
|
329
|
+
const platformMethods = await importPlatformMethods();
|
|
330
|
+
await platformMethods.executeTrustQuery({
|
|
333
331
|
logger,
|
|
334
|
-
certificate: rootCertificate,
|
|
335
|
-
certificateFileUrl: rootCertificateFileInfo.url,
|
|
336
332
|
certificateCommonName: rootCertificateCommonName,
|
|
333
|
+
certificateFileUrl: rootCertificateFileInfo.url,
|
|
334
|
+
certificate: rootCertificate,
|
|
335
|
+
verb: "REMOVE_TRUST",
|
|
337
336
|
});
|
|
338
337
|
}
|
|
339
338
|
filesToRemove.push(rootCertificateFileInfo.url);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { writeFileSync } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE, createDetailedMessage, createLogger } from "@jsenv/
|
|
2
|
+
import { UNICODE, createDetailedMessage, createLogger } from "@jsenv/humanize";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
|
-
|
|
5
4
|
import { getAuthorityFileInfos } from "./internal/authority_file_infos.js";
|
|
6
5
|
import { requestCertificateFromAuthority } from "./internal/certificate_generator.js";
|
|
7
6
|
import { forge } from "./internal/forge.js";
|
|
@@ -47,7 +46,9 @@ export const requestCertificate = ({
|
|
|
47
46
|
} = getAuthorityFileInfos();
|
|
48
47
|
if (!rootCertificateFileInfo.exists) {
|
|
49
48
|
throw new Error(
|
|
50
|
-
`Certificate authority not found, "installCertificateAuthority" must be called before "requestServerCertificate"
|
|
49
|
+
`Certificate authority not found, "installCertificateAuthority" must be called before "requestServerCertificate".
|
|
50
|
+
--- Suggested command to run ---
|
|
51
|
+
npx @jsenv/https-local install --trust`,
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
if (!rootCertificatePrivateKeyFileInfo.exists) {
|
|
@@ -84,7 +85,6 @@ export const requestCertificate = ({
|
|
|
84
85
|
logger.debug(`Generating server certificate...`);
|
|
85
86
|
const { certificateForgeObject, certificatePrivateKeyForgeObject } =
|
|
86
87
|
requestCertificateFromAuthority({
|
|
87
|
-
logger,
|
|
88
88
|
authorityCertificateForgeObject: rootCertificateForgeObject,
|
|
89
89
|
auhtorityCertificatePrivateKeyForgeObject:
|
|
90
90
|
rootCertificatePrivateKeyForgeObject,
|
package/src/hosts_file_verif.js
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
installCertificateAuthority,
|
|
5
|
+
requestCertificate,
|
|
6
|
+
uninstallCertificateAuthority,
|
|
7
|
+
verifyHostsFile,
|
|
8
|
+
} from "@jsenv/https-local";
|
|
9
|
+
import { writeFileSync } from "node:fs";
|
|
10
|
+
import { parseArgs } from "node:util";
|
|
11
|
+
|
|
12
|
+
const options = {
|
|
13
|
+
"help": {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
},
|
|
16
|
+
"trust": {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
},
|
|
19
|
+
"certificate": {
|
|
20
|
+
type: "string",
|
|
21
|
+
},
|
|
22
|
+
"private-key": {
|
|
23
|
+
type: "string",
|
|
24
|
+
},
|
|
25
|
+
"hostnames": {
|
|
26
|
+
type: "string",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const { values, positionals } = parseArgs({
|
|
30
|
+
options,
|
|
31
|
+
allowPositionals: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (values.help || positionals.length === 0) {
|
|
35
|
+
console.log(`https-local: Generate https certificates to use on your machine.
|
|
36
|
+
|
|
37
|
+
Usage:
|
|
38
|
+
|
|
39
|
+
npx @jsenv/https-local setup
|
|
40
|
+
Install root certificate, try to trust it and ensure localhost is mapped to 127.0.0.1
|
|
41
|
+
|
|
42
|
+
npx @jsenv/https-local install --trust
|
|
43
|
+
Install root certificate on the filesystem
|
|
44
|
+
- trust: Try to add root certificate to os and browser trusted stores.
|
|
45
|
+
|
|
46
|
+
npx @jsenv/https-local uninstall
|
|
47
|
+
Uninstall root certificate from the filesystem
|
|
48
|
+
|
|
49
|
+
npx @jsenv/https-local localhost-mapping
|
|
50
|
+
Ensure localhost mapping to 127.0.0.1 is set on the filesystem
|
|
51
|
+
|
|
52
|
+
npx @jsenv/https-local generate
|
|
53
|
+
Generate a server certificate and write it to files
|
|
54
|
+
- certificate: Path where to write the certificate file (default: certificate.pem)
|
|
55
|
+
- private-key: Path where to write the private key file (default: private_key.pem)
|
|
56
|
+
- hostnames: Comma-separated list of hostnames (default: localhost)
|
|
57
|
+
|
|
58
|
+
https://github.com/jsenv/core/tree/main/packages/tooling/https-local
|
|
59
|
+
|
|
60
|
+
`);
|
|
61
|
+
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const commandHandlers = {
|
|
66
|
+
setup: async () => {
|
|
67
|
+
await installCertificateAuthority({
|
|
68
|
+
tryToTrust: true,
|
|
69
|
+
NSSDynamicInstall: true,
|
|
70
|
+
});
|
|
71
|
+
await verifyHostsFile({
|
|
72
|
+
ipMappings: {
|
|
73
|
+
"127.0.0.1": ["localhost"],
|
|
74
|
+
},
|
|
75
|
+
tryToUpdateHostsFile: true,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
install: async ({ trust }) => {
|
|
79
|
+
await installCertificateAuthority({
|
|
80
|
+
tryToTrust: trust,
|
|
81
|
+
NSSDynamicInstall: trust,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
uninstall: async () => {
|
|
85
|
+
await uninstallCertificateAuthority({
|
|
86
|
+
tryToUntrust: true,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
["localhost-mapping"]: async () => {
|
|
90
|
+
await verifyHostsFile({
|
|
91
|
+
ipMappings: {
|
|
92
|
+
"127.0.0.1": ["localhost"],
|
|
93
|
+
},
|
|
94
|
+
tryToUpdateHostsFile: true,
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
generate: async ({ certificate, "private-key": privateKey, hostnames }) => {
|
|
98
|
+
const certificateFilePath = certificate || "certificate.pem";
|
|
99
|
+
const privateKeyFilePath = privateKey || "private_key.pem";
|
|
100
|
+
const altNames = hostnames ? hostnames.split(",") : ["localhost"];
|
|
101
|
+
const result = requestCertificate({ altNames });
|
|
102
|
+
writeFileSync(certificateFilePath, result.certificate);
|
|
103
|
+
writeFileSync(privateKeyFilePath, result.privateKey);
|
|
104
|
+
console.log(`certificate written to ${certificateFilePath}`);
|
|
105
|
+
console.log(`private key written to ${privateKeyFilePath}`);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const [command] = positionals;
|
|
110
|
+
const commandHandler = commandHandlers[command];
|
|
111
|
+
if (!commandHandler) {
|
|
112
|
+
console.error(`Error: unknown command ${command}.`);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
await commandHandler(values);
|
|
@@ -8,9 +8,8 @@ export const parseHosts = (
|
|
|
8
8
|
const lines = [];
|
|
9
9
|
hosts.split(/\r?\n/).forEach((line) => {
|
|
10
10
|
const lineWithoutComments = line.replace(/#.*/, "");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
11
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
12
|
+
const matches = /^\s*?(.+?)\s+(.+?)\s*$/.exec(lineWithoutComments);
|
|
14
13
|
if (matches && matches.length === 3) {
|
|
15
14
|
const [, ip, host] = matches;
|
|
16
15
|
const hostnames = host.split(" ");
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE } from "@jsenv/
|
|
2
|
+
import { UNICODE } from "@jsenv/humanize";
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
|
|
5
4
|
import { executeTrustQueryOnBrowserNSSDB } from "../nssdb_browser.js";
|
|
6
5
|
import {
|
|
7
6
|
detectIfNSSIsInstalled,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE } from "@jsenv/
|
|
2
|
+
import { UNICODE } from "@jsenv/humanize";
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
|
|
5
4
|
import { executeTrustQueryOnBrowserNSSDB } from "../nssdb_browser.js";
|
|
6
5
|
import {
|
|
7
6
|
detectIfNSSIsInstalled,
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { readFile } from "@jsenv/filesystem";
|
|
6
|
-
import { createDetailedMessage, UNICODE } from "@jsenv/
|
|
6
|
+
import { createDetailedMessage, UNICODE } from "@jsenv/humanize";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
|
|
10
9
|
import { exec } from "../exec.js";
|
|
11
10
|
import {
|
|
12
11
|
VERB_ADD_TRUST,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE, createTaskLog } from "@jsenv/
|
|
2
|
+
import { UNICODE, createTaskLog } from "@jsenv/humanize";
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
|
|
5
4
|
import { executeTrustQueryOnBrowserNSSDB } from "../nssdb_browser.js";
|
|
6
5
|
import {
|
|
7
6
|
detectIfNSSIsInstalled,
|
package/src/internal/mac/mac.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// https://ss64.com/osx/security.html
|
|
2
2
|
|
|
3
|
-
import { createDetailedMessage, UNICODE } from "@jsenv/
|
|
3
|
+
import { createDetailedMessage, UNICODE } from "@jsenv/humanize";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
5
|
import { exec } from "../exec.js";
|
|
7
6
|
import { searchCertificateInCommandOutput } from "../search_certificate_in_command_output.js";
|
|
8
7
|
import {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
2
|
-
import { UNICODE } from "@jsenv/
|
|
2
|
+
import { UNICODE } from "@jsenv/humanize";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
4
|
import { commandExists } from "../command.js";
|
|
6
5
|
import { exec } from "../exec.js";
|
|
7
6
|
import { memoize } from "../memoize.js";
|
|
@@ -7,11 +7,10 @@ import {
|
|
|
7
7
|
assertAndNormalizeDirectoryUrl,
|
|
8
8
|
collectFiles,
|
|
9
9
|
} from "@jsenv/filesystem";
|
|
10
|
-
import { createDetailedMessage, UNICODE } from "@jsenv/
|
|
10
|
+
import { createDetailedMessage, UNICODE } from "@jsenv/humanize";
|
|
11
11
|
import { urlToFilename } from "@jsenv/urls";
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
|
|
15
14
|
import { detectBrowser } from "./browser_detection.js";
|
|
16
15
|
import { exec } from "./exec.js";
|
|
17
16
|
import { searchCertificateInCommandOutput } from "./search_certificate_in_command_output.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UNICODE } from "@jsenv/
|
|
1
|
+
import { UNICODE } from "@jsenv/humanize";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
-
|
|
5
4
|
import { memoize } from "../memoize.js";
|
|
6
5
|
|
|
7
6
|
const require = createRequire(import.meta.url);
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* - A way to install and use NSS command on windows to update firefox NSS dabatase file
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { UNICODE } from "@jsenv/
|
|
6
|
+
import { UNICODE } from "@jsenv/humanize";
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
|
-
|
|
10
9
|
import { memoize } from "../memoize.js";
|
|
11
10
|
|
|
12
11
|
const require = createRequire(import.meta.url);
|
|
@@ -14,7 +14,6 @@ export const executeTrustQuery = async ({
|
|
|
14
14
|
certificateCommonName,
|
|
15
15
|
certificateFileUrl,
|
|
16
16
|
certificateIsNew,
|
|
17
|
-
certificate,
|
|
18
17
|
verb,
|
|
19
18
|
}) => {
|
|
20
19
|
const windowsTrustInfo = await executeTrustQueryOnWindows({
|
|
@@ -22,7 +21,6 @@ export const executeTrustQuery = async ({
|
|
|
22
21
|
certificateCommonName,
|
|
23
22
|
certificateFileUrl,
|
|
24
23
|
certificateIsNew,
|
|
25
|
-
certificate,
|
|
26
24
|
verb,
|
|
27
25
|
});
|
|
28
26
|
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { createDetailedMessage, UNICODE } from "@jsenv/
|
|
6
|
+
import { createDetailedMessage, UNICODE } from "@jsenv/humanize";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
8
|
import { exec } from "../exec.js";
|
|
10
9
|
import {
|
|
11
10
|
VERB_ADD_TRUST,
|
package/src/main.js
CHANGED
|
@@ -12,12 +12,9 @@ export {
|
|
|
12
12
|
installCertificateAuthority,
|
|
13
13
|
uninstallCertificateAuthority,
|
|
14
14
|
} from "./certificate_authority.js";
|
|
15
|
-
|
|
15
|
+
export { requestCertificate } from "./certificate_request.js";
|
|
16
|
+
export { verifyHostsFile } from "./hosts_file_verif.js";
|
|
16
17
|
export {
|
|
17
18
|
createValidityDurationOfXDays,
|
|
18
19
|
createValidityDurationOfXYears,
|
|
19
20
|
} from "./validity_duration.js";
|
|
20
|
-
|
|
21
|
-
export { verifyHostsFile } from "./hosts_file_verif.js";
|
|
22
|
-
|
|
23
|
-
export { requestCertificate } from "./certificate_request.js";
|