load_pkey_pem: Check for spurious errors when loading
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15949)
This commit is contained in:
parent
66a7c9f34b
commit
bb8a24503c
@ -73,9 +73,17 @@ EVP_PKEY *load_pkey_pem(const char *file, OSSL_LIB_CTX *libctx)
|
||||
|
||||
if (!TEST_ptr(file) || !TEST_ptr(bio = BIO_new(BIO_s_file())))
|
||||
return NULL;
|
||||
if (TEST_int_gt(BIO_read_filename(bio, file), 0))
|
||||
(void)TEST_ptr(key = PEM_read_bio_PrivateKey_ex(bio, NULL, NULL, NULL,
|
||||
libctx, NULL));
|
||||
if (TEST_int_gt(BIO_read_filename(bio, file), 0)) {
|
||||
unsigned long err = ERR_peek_error();
|
||||
|
||||
if (TEST_ptr(key = PEM_read_bio_PrivateKey_ex(bio, NULL, NULL, NULL,
|
||||
libctx, NULL))
|
||||
&& err != ERR_peek_error()) {
|
||||
TEST_info("Spurious error from reading PEM");
|
||||
EVP_PKEY_free(key);
|
||||
key = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BIO_free(bio);
|
||||
return key;
|
||||
|
Loading…
x
Reference in New Issue
Block a user