Commit 5ca12ed
authored
fix(ext/node): extract cert/key from pfx in tls SecureContext (#34383)
`tls.createServer({ pfx, passphrase, ... })` and `tls.connect({ pfx,
... })` were validating the PFX but never extracting its contents, so
the SecureContext ended up with no `cert`/`key`. The server installed
`NoCertResolver` and the TLS handshake aborted with
`ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE` / client-side `ECONNRESET`,
even though both peers had `rejectUnauthorized: false` — making
`pfx`-only configs unusable.
Replace `op_node_validate_pfx` with `op_node_load_pfx`, which decrypts
the PFX with the passphrase and returns the leaf cert, the private key
(PKCS#8) and any additional certs as PEM. `_tls_common.ts` falls back
to those values when explicit `cert`/`key`/`ca` aren't provided, so
an explicit `cert` still takes precedence over the PFX leaf.
Also map the server-side `authorizationError` for a self-signed leaf
with no CA configured to `DEPTH_ZERO_SELF_SIGNED_CERT` instead of
always reporting `UNABLE_TO_GET_ISSUER_CERT`, matching Node/OpenSSL.
p12 0.6's MAC verification only knows SHA-1 and panics via
`debug_assert!` on newer SHA-256 PFX files, so wrap the call in
`catch_unwind` and treat any non-SHA-1 MAC as unverifiable rather than
a hard failure — PBE-decryption of the bags provides the real
integrity check.
Fixes #342021 parent 7aadfe8 commit 5ca12ed
11 files changed
Lines changed: 231 additions & 44 deletions
File tree
- ext
- node_crypto
- node
- ops
- polyfills
- tests
- testdata/tls
- unit_node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3450 | 3450 | | |
3451 | 3451 | | |
3452 | 3452 | | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
3453 | 3458 | | |
3454 | 3459 | | |
3455 | 3460 | | |
| |||
4206 | 4211 | | |
4207 | 4212 | | |
4208 | 4213 | | |
4209 | | - | |
4210 | | - | |
| 4214 | + | |
| 4215 | + | |
4211 | 4216 | | |
4212 | 4217 | | |
4213 | | - | |
4214 | | - | |
| 4218 | + | |
| 4219 | + | |
| 4220 | + | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
4215 | 4228 | | |
4216 | | - | |
| 4229 | + | |
4217 | 4230 | | |
4218 | 4231 | | |
4219 | 4232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
503 | 512 | | |
504 | 513 | | |
505 | 514 | | |
| |||
522 | 531 | | |
523 | 532 | | |
524 | 533 | | |
525 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
526 | 543 | | |
527 | 544 | | |
528 | 545 | | |
| |||
544 | 561 | | |
545 | 562 | | |
546 | 563 | | |
547 | | - | |
| 564 | + | |
| 565 | + | |
548 | 566 | | |
549 | | - | |
| 567 | + | |
550 | 568 | | |
551 | | - | |
552 | | - | |
| 569 | + | |
| 570 | + | |
553 | 571 | | |
554 | 572 | | |
555 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4156 | 4156 | | |
4157 | 4157 | | |
4158 | 4158 | | |
4159 | | - | |
| 4159 | + | |
4160 | 4160 | | |
4161 | 4161 | | |
4162 | 4162 | | |
4163 | 4163 | | |
4164 | 4164 | | |
4165 | 4165 | | |
| 4166 | + | |
| 4167 | + | |
| 4168 | + | |
| 4169 | + | |
| 4170 | + | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
| 4180 | + | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
| 4193 | + | |
| 4194 | + | |
| 4195 | + | |
| 4196 | + | |
| 4197 | + | |
| 4198 | + | |
| 4199 | + | |
| 4200 | + | |
4166 | 4201 | | |
4167 | 4202 | | |
4168 | 4203 | | |
| |||
4176 | 4211 | | |
4177 | 4212 | | |
4178 | 4213 | | |
4179 | | - | |
| 4214 | + | |
| 4215 | + | |
4180 | 4216 | | |
4181 | 4217 | | |
4182 | | - | |
4183 | | - | |
4184 | | - | |
| 4218 | + | |
| 4219 | + | |
4185 | 4220 | | |
4186 | 4221 | | |
4187 | | - | |
4188 | | - | |
4189 | | - | |
4190 | | - | |
4191 | | - | |
4192 | | - | |
4193 | | - | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
| 4233 | + | |
| 4234 | + | |
| 4235 | + | |
| 4236 | + | |
| 4237 | + | |
| 4238 | + | |
| 4239 | + | |
| 4240 | + | |
| 4241 | + | |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
4194 | 4245 | | |
4195 | | - | |
4196 | | - | |
4197 | | - | |
4198 | | - | |
4199 | | - | |
4200 | | - | |
4201 | | - | |
4202 | | - | |
4203 | | - | |
4204 | | - | |
4205 | | - | |
4206 | | - | |
4207 | | - | |
4208 | | - | |
4209 | | - | |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
4210 | 4256 | | |
4211 | | - | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
| 4264 | + | |
| 4265 | + | |
| 4266 | + | |
| 4267 | + | |
| 4268 | + | |
| 4269 | + | |
| 4270 | + | |
| 4271 | + | |
| 4272 | + | |
4212 | 4273 | | |
4213 | 4274 | | |
4214 | 4275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments