Skip to content

Unexpected openssl error with Node 12.18.0 custom build #35456

Closed
@liweixi100

Description

@liweixi100
  • Version: 12.18.0 (built with "--openssl-system-ca-path")
  • Platform: Redhat Linux 7.6
  • Subsystem: Linux 3.10.0-957.35.2.el7.x86_64 deps: update openssl to 1.0.1j #1 SMP Wed Sep 18 05:51:28 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux

What steps will reproduce the bug?

Our app would crash at runtime if the --openssl-system-ca-path referenced path did not exist.

How often does it reproduce? Is there a required condition?

The crash was observed every time with our app. However, we could not reproduce the crash with a simple script. Our app had a much more complicated dependencies.

What is the expected behavior?

Before 12.18.0, even if the --openssl-system-ca-path referenced path did not exist, the app would run just fine.

What do you see instead?

Our app crashed every time with following traces:

`Error: error:02001002:system library:fopen:No such file or directory
    at Sign.sign (internal/crypto/sig.js:105:29)
    at SAML.signRequest (/mybackend/node_modules/passport-saml/lib/passport-saml/saml.js:137:38)
    at DeflateRaw.requestToUrlHelper [as cb] (/mybackend/node_modules/passport-saml/lib/passport-saml/saml.js:313:12)
    at DeflateRaw.zlibBufferOnEnd (zlib.js:149:10)
    at DeflateRaw.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  opensslErrorStack: [
    'error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib',
    'error:2006D080:BIO routines:BIO_new_file:no such file'
  ],
  library: 'system library',
  function: 'fopen',
  reason: 'No such file or directory',
  code: 'ERR_OSSL_SYS_NO_SUCH_FILE_OR_DIRECTORY'
}

Additional information

We have been making a custom build of node using the --openssl-system-ca-path configure option. Recently we noticed the crash when we upgraded from 12.16.3 to 12.18.0.

It turned out the crash was related to openssl-system-ca-path build config --- if the environment did not contain a valid path for the cert, our app would crash. If the cert path existed, it would not crash.

However, that was not the behavior we saw prior to the 12.18.0 version.

We also found a workaround: if the process was started with NODE_EXTRA_CA_CERTS=/path/to/cert.pem, then the crash would go away. This was true even if the path did not exist at all; as long as the NODE_EXTRA_CA_CERTS env was set to anything, it would not crash.

This was the PR for the openssl-system-ca-path feature that was created by @danbev

We'd like to clarify:

  1. Does the --openssl-system-ca-path build option compile in the content of the certificate, or does it only compile in the path of it? (I think it was the latter, but wanted to be sure.)

  2. What is the expected runtime behavior of custom build made with openssl-system-ca-path: if the cert does not exist, shouldn't it fallback to the built-in CA?

  3. Could there be any recent changes that made the ca-path-not-exit error become a fatal exception?

Metadata

Metadata

Assignees

No one assigned

    Labels

    opensslIssues and PRs related to the OpenSSL dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions