openssl / openssl/openssl

OpenSSLv3 - loading certificates is much slower than previous versions

Open
#16,871 9 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

branch: master triaged: feature
Dominant language
C
Stars
30.8k
Forks
11.5k
Avg merge
10m
Merged PRs (30d)
1

Description

Recreated on Linux x64 and Windows x64 with Node.js 17 that uses OpenSSL v3

Node.js provides the option to add extra certificates. When this is done the certificates are loaded using PEM_read_bio_X509 as follows:

if (root_certs_vector.empty() &&
      per_process::cli_options->ssl_openssl_cert_store == false) {
    for (size_t i = 0; i < arraysize(root_certs); i++) {
      X509* x509 =
          PEM_read_bio_X509(NodeBIO::NewFixed(root_certs[i],
                                              strlen(root_certs[i])).get(),
                            nullptr,   // no re-use of X509 structure
                            NoPasswordCallback,
                            nullptr);  // no callback data

      // Parse errors from the built-in roots are fatal.
      CHECK_NOT_NULL(x509);

      root_certs_vector.push_back(x509);
    }
  }

This seems to be much slower in OpenSSL v3 (which is what was pulled into Node.js 17) versus earlier versions. Loading extra certificates seems to add 60 or more milliseconds (will vary by machine) than it did before. Since startup time is only 40ms on the same machine without extra certificates going from 40 to over 100ms is pretty significant.

Is this a known issue or expected? I searched through github and the release notes but I've not been able to find anything that might explain or suggest this would be expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the shown PEM_read_bio_X509 path that loads extra certificates and compare its behavior under OpenSSL v3 with earlier versions. Profile certificate loading on Linux or Windows and determine whether the added startup time is expected or represents a regression; the issue is complete when the cause and expected behavior are documented or an actionable fix is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cryptography, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.