From: Richard Levitte Date: Tue, 18 Aug 2020 19:45:19 +0000 (+0200) Subject: TEST: Use PEM_read_bio_PUBKEY_ex() and PEM_read_bio_PrivateKey_ex() X-Git-Tag: openssl-3.0.0-alpha7~548 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f2b7db09b6f9650ecf2b465ee9f737385623bd5;p=thirdparty%2Fopenssl.git TEST: Use PEM_read_bio_PUBKEY_ex() and PEM_read_bio_PrivateKey_ex() test/evp_test.c and test/sslapitest.c are affected. This allows them to decode keys found in stanza files via provider decoder implementations when a library context other than the default should be used. Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/12673) --- diff --git a/test/evp_test.c b/test/evp_test.c index cd6077e10d0..958718b1ba7 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -3342,7 +3342,7 @@ start: } klist = &private_keys; } else if (strcmp(pp->key, "PublicKey") == 0) { - pkey = PEM_read_bio_PUBKEY(t->s.key, NULL, 0, NULL); + pkey = PEM_read_bio_PUBKEY_ex(t->s.key, NULL, 0, NULL, libctx, NULL); if (pkey == NULL && !key_unsupported()) { EVP_PKEY_free(pkey); TEST_info("Can't read public key %s", pp->value); diff --git a/test/sslapitest.c b/test/sslapitest.c index 6f4c11537b0..cf9947ea0b2 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -7511,7 +7511,9 @@ static int cert_cb(SSL *s, void *arg) BIO_free(in); if (!TEST_ptr(in = BIO_new(BIO_s_file())) || !TEST_int_ge(BIO_read_filename(in, ecdsakey), 0) - || !TEST_ptr(pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL))) + || !TEST_ptr(pkey = PEM_read_bio_PrivateKey_ex(in, NULL, + NULL, NULL, + libctx, NULL))) goto out; rv = SSL_check_chain(s, x509, pkey, chain); /* @@ -7656,8 +7658,9 @@ static int client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) if (!TEST_ptr(xcert = X509_new_with_libctx(libctx, NULL)) || !TEST_ptr(PEM_read_bio_X509(in, &xcert, NULL, NULL)) || !TEST_ptr(priv_in = BIO_new_file(privkey, "r")) - || !TEST_ptr(privpkey = PEM_read_bio_PrivateKey(priv_in, NULL, NULL, - NULL))) + || !TEST_ptr(privpkey = PEM_read_bio_PrivateKey_ex(priv_in, NULL, + NULL, NULL, + libctx, NULL))) goto err; *x509 = xcert;