diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-27 15:03:06 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-05 17:39:27 +1000 |
commit | d2b6c06274f37c5c6c967939ee556c4be5b568d0 (patch) | |
tree | 8aa39fb3aa61f76fe8a9bf4728e8badb5b970814 /test | |
parent | 7be04a3ac40fb6cf83be2c619dc30625988c6742 (diff) | |
download | openssl-d2b6c06274f37c5c6c967939ee556c4be5b568d0.zip openssl-d2b6c06274f37c5c6c967939ee556c4be5b568d0.tar.gz openssl-d2b6c06274f37c5c6c967939ee556c4be5b568d0.tar.bz2 |
Ensure libctx/propq is propagated when handling X509_REQ
When we create via d2i or dup an X509_REQ we should ensure that the libctx
is properly propagated. We also ensure we create X509_REQ objects with the
proper libctx assigned in the CMP tests.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15591)
Diffstat (limited to 'test')
-rw-r--r-- | test/cmp_client_test.c | 2 | ||||
-rw-r--r-- | test/cmp_msg_test.c | 4 | ||||
-rw-r--r-- | test/testutil.h | 2 | ||||
-rw-r--r-- | test/testutil/load.c | 7 |
4 files changed, 9 insertions, 6 deletions
diff --git a/test/cmp_client_test.c b/test/cmp_client_test.c index 863a765..f470f5e 100644 --- a/test/cmp_client_test.c +++ b/test/cmp_client_test.c @@ -223,7 +223,7 @@ static int test_exec_P10CR_ses(void) SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up); fixture->req_type = OSSL_CMP_P10CR; fixture->expected = 1; - if (!TEST_ptr(req = load_csr_der(pkcs10_f)) + if (!TEST_ptr(req = load_csr_der(pkcs10_f, libctx)) || !TEST_true(OSSL_CMP_CTX_set1_p10CSR(fixture->cmp_ctx, req))) { tear_down(fixture); fixture = NULL; diff --git a/test/cmp_msg_test.c b/test/cmp_msg_test.c index a9a858c..4f2ca1b 100644 --- a/test/cmp_msg_test.c +++ b/test/cmp_msg_test.c @@ -226,7 +226,7 @@ static int test_cmp_create_p10cr(void) fixture->bodytype = OSSL_CMP_PKIBODY_P10CR; fixture->err_code = CMP_R_ERROR_CREATING_CERTREQ; fixture->expected = 1; - if (!TEST_ptr(p10cr = load_csr_der(pkcs10_f)) + if (!TEST_ptr(p10cr = load_csr_der(pkcs10_f, libctx)) || !TEST_true(set1_newPkey(ctx, newkey)) || !TEST_true(OSSL_CMP_CTX_set1_p10CSR(ctx, p10cr))) { tear_down(fixture); @@ -504,7 +504,7 @@ static int test_cmp_pkimessage_create(int bodytype) switch (fixture->bodytype = bodytype) { case OSSL_CMP_PKIBODY_P10CR: fixture->expected = 1; - p10cr = load_csr_der(pkcs10_f); + p10cr = load_csr_der(pkcs10_f, libctx); if (!TEST_true(OSSL_CMP_CTX_set1_p10CSR(fixture->cmp_ctx, p10cr))) { tear_down(fixture); fixture = NULL; diff --git a/test/testutil.h b/test/testutil.h index 710f51c..c28df70 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -592,6 +592,6 @@ EVP_PKEY *load_pkey_pem(const char *file, OSSL_LIB_CTX *libctx); X509 *load_cert_pem(const char *file, OSSL_LIB_CTX *libctx); X509 *load_cert_der(const unsigned char *bytes, int len); STACK_OF(X509) *load_certs_pem(const char *file); -X509_REQ *load_csr_der(const char *file); +X509_REQ *load_csr_der(const char *file, OSSL_LIB_CTX *libctx); #endif /* OSSL_TESTUTIL_H */ diff --git a/test/testutil/load.c b/test/testutil/load.c index 444fb8a..be30d7e 100644 --- a/test/testutil/load.c +++ b/test/testutil/load.c @@ -81,14 +81,17 @@ EVP_PKEY *load_pkey_pem(const char *file, OSSL_LIB_CTX *libctx) return key; } -X509_REQ *load_csr_der(const char *file) +X509_REQ *load_csr_der(const char *file, OSSL_LIB_CTX *libctx) { X509_REQ *csr = NULL; BIO *bio = NULL; if (!TEST_ptr(file) || !TEST_ptr(bio = BIO_new_file(file, "rb"))) return NULL; - (void)TEST_ptr(csr = d2i_X509_REQ_bio(bio, NULL)); + + csr = X509_REQ_new_ex(libctx, NULL); + if (TEST_ptr(csr)) + (void)TEST_ptr(d2i_X509_REQ_bio(bio, &csr)); BIO_free(bio); return csr; } |