GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: return a clearer error when loading an unsupported pkcs12 · nodejs/node@a5984e4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_context.cc
  • test
    • fixtures/keys
      • legacy.pfx
    • parallel
      • test-tls-legacy-pfx.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_context.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,16 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
11101110
if (!ret) {
11111111
// TODO(@jasnell): Should this use ThrowCryptoError?
11121112
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
1113+
1114+
#if OPENSSL_VERSION_MAJOR >= 3
1115+
if (ERR_GET_REASON(err) == ERR_R_UNSUPPORTED) {
1116+
// OpenSSL's "unsupported" error without any context is very
1117+
// common and not very helpful, so we override it:
1118+
return THROW_ERR_CRYPTO_UNSUPPORTED_OPERATION(
1119+
env, "Unsupported PKCS12 PFX data");
1120+
}
1121+
#endif
1122+
11131123
const char* str = ERR_reason_error_string(err);
11141124
str = str != nullptr ? str : "Unknown error";
11151125

Collapse file

‎test/fixtures/keys/legacy.pfx‎

Copy file name to clipboard
1.03 KB
Binary file not shown.
Collapse file

‎test/parallel/test-tls-legacy-pfx.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
const common = require('../common');
3+
if (!common.hasCrypto)
4+
common.skip('missing crypto');
5+
if (!common.hasOpenSSL3)
6+
common.skip('OpenSSL legacy failures are only testable with OpenSSL 3+');
7+
8+
const fixtures = require('../common/fixtures');
9+
10+
const {
11+
assert, connect, keys
12+
} = require(fixtures.path('tls-connect'));
13+
14+
const legacyPfx = fixtures.readKey('legacy.pfx');
15+
16+
connect({
17+
client: {
18+
pfx: legacyPfx,
19+
passphrase: 'legacy',
20+
rejectUnauthorized: false
21+
},
22+
server: keys.agent1
23+
}, common.mustCall((e, pair, cleanup) => {
24+
assert.strictEqual(e.code, 'ERR_CRYPTO_UNSUPPORTED_OPERATION');
25+
assert.strictEqual(e.message, 'Unsupported PKCS12 PFX data');
26+
cleanup();
27+
}));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.