summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTodd Short <tshort@akamai.com>2019-04-11 10:47:13 -0400
committerRichard Levitte <levitte@openssl.org>2020-07-16 09:08:21 +0200
commit8c2bfd25129aea1b1f1b66ec753b21955f8ed523 (patch)
tree530798b60ed46a10265c5a061dedfd2694918ce3 /test
parent55affcadbe4aac7d4832448b8c071b582da4e344 (diff)
Add SSL_get[01]_peer_certificate()
Deprecate SSL_get_peer_certificte() and replace with SSL_get1_peer_certificate(). Add SSL_get0_peer_certificate. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/8730)
Diffstat (limited to 'test')
-rw-r--r--test/handshake_helper.c10
-rw-r--r--test/ossl_shim/ossl_shim.cc2
-rw-r--r--test/sslapitest.c8
-rw-r--r--test/ssltest_old.c3
4 files changed, 8 insertions, 15 deletions
diff --git a/test/handshake_helper.c b/test/handshake_helper.c
index 2dfded5c11..bc6762d475 100644
--- a/test/handshake_helper.c
+++ b/test/handshake_helper.c
@@ -1285,14 +1285,10 @@ static int pkey_type(EVP_PKEY *pkey)
static int peer_pkey_type(SSL *s)
{
- X509 *x = SSL_get_peer_certificate(s);
+ X509 *x = SSL_get0_peer_certificate(s);
- if (x != NULL) {
- int nid = pkey_type(X509_get0_pubkey(x));
-
- X509_free(x);
- return nid;
- }
+ if (x != NULL)
+ return pkey_type(X509_get0_pubkey(x));
return NID_undef;
}
diff --git a/test/ossl_shim/ossl_shim.cc b/test/ossl_shim/ossl_shim.cc
index 0184778d4f..d4d7cf1454 100644
--- a/test/ossl_shim/ossl_shim.cc
+++ b/test/ossl_shim/ossl_shim.cc
@@ -894,7 +894,7 @@ static bool CheckHandshakeProperties(SSL *ssl, bool is_resume) {
return false;
}
} else if (!config->is_server || config->require_any_client_certificate) {
- if (SSL_get_peer_certificate(ssl) == nullptr) {
+ if (SSL_get0_peer_certificate(ssl) == nullptr) {
fprintf(stderr, "Received no peer certificate but expected one.\n");
return false;
}
diff --git a/test/sslapitest.c b/test/sslapitest.c
index afc4ea8d40..1a91f96fb9 100644
--- a/test/sslapitest.c
+++ b/test/sslapitest.c
@@ -7623,15 +7623,13 @@ static int test_cert_cb(int tst)
static int client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{
- X509 *xcert, *peer;
+ X509 *xcert;
EVP_PKEY *privpkey;
BIO *in = NULL;
- /* Check that SSL_get_peer_certificate() returns something sensible */
- peer = SSL_get_peer_certificate(ssl);
- if (!TEST_ptr(peer))
+ /* Check that SSL_get0_peer_certificate() returns something sensible */
+ if (!TEST_ptr(SSL_get0_peer_certificate(ssl)))
return 0;
- X509_free(peer);
in = BIO_new_file(cert, "r");
if (!TEST_ptr(in))
diff --git a/test/ssltest_old.c b/test/ssltest_old.c
index d45b2786d3..4f340fc2e0 100644
--- a/test/ssltest_old.c
+++ b/test/ssltest_old.c
@@ -781,7 +781,7 @@ static void print_details(SSL *c_ssl, const char *prefix)
prefix,
SSL_get_version(c_ssl),
SSL_CIPHER_get_version(ciph), SSL_CIPHER_get_name(ciph));
- cert = SSL_get_peer_certificate(c_ssl);
+ cert = SSL_get0_peer_certificate(c_ssl);
if (cert != NULL) {
EVP_PKEY* pubkey = X509_get0_pubkey(cert);
@@ -789,7 +789,6 @@ static void print_details(SSL *c_ssl, const char *prefix)
BIO_puts(bio_stdout, ", ");
print_key_details(bio_stdout, pubkey);
}
- X509_free(cert);
}
if (SSL_get_peer_tmp_key(c_ssl, &pkey)) {
BIO_puts(bio_stdout, ", temp key: ");