-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: mark/pop OpenSSL errors in NewRootCertStore
This commit sets the OpenSSL error mark before calling X509_STORE_load_locations and pops the error mark afterwards. The motivation for this is that it is possible that X509_STORE_load_locations can produce errors if the configuration option --openssl-system-ca-path file does not exist. Later if a different function is called which calls an OpenSSL function it could fail because these errors might still be on the OpenSSL error stack. Currently, all functions that call NewRootCertStore clear the OpenSSL error queue upon returning, but this was not the case for example in v12.18.0. PR-URL: #35514 Fixes: #35456 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
1 parent
c509485
commit 6a7a61b
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// This simulates specifying the configuration option --openssl-system-ca-path | ||
// and settting it to a file that does not exist. | ||
#define NODE_OPENSSL_SYSTEM_CERT_PATH "/missing/ca.pem" | ||
|
||
#include "crypto/crypto_context.h" | ||
#include "node_options.h" | ||
#include "openssl/err.h" | ||
#include "gtest/gtest.h" | ||
|
||
/* | ||
* This test verifies that a call to NewRootCertDir with the build time | ||
* configuration option --openssl-system-ca-path set to an missing file, will | ||
* not leave any OpenSSL errors on the OpenSSL error stack. | ||
* See https://github.com/nodejs/node/issues/35456 for details. | ||
*/ | ||
TEST(NodeCrypto, NewRootCertStore) { | ||
node::per_process::cli_options->ssl_openssl_cert_store = true; | ||
X509_STORE* store = node::crypto::NewRootCertStore(); | ||
ASSERT_TRUE(store); | ||
ASSERT_EQ(ERR_peek_error(), 0UL) << "NewRootCertStore should not have left " | ||
"any errors on the OpenSSL error stack\n"; | ||
X509_STORE_free(store); | ||
} |