add test for get0 session peer certificate

This commit is contained in:
Jacob Barthelmeh
2020-01-27 13:34:16 -07:00
committed by Eric Blankenhorn
parent 653235cd57
commit 49def96998
2 changed files with 15 additions and 1 deletions

View File

@@ -13465,7 +13465,7 @@ WOLFSSL_X509* wolfSSL_SESSION_get0_peer(WOLFSSL_SESSION* session)
WOLFSSL_MSG("bad count found");
return NULL;
}
return wolfSSL_get_chain_X509(&session->chain, count - 1);
return wolfSSL_get_chain_X509(&session->chain, 0);
}
WOLFSSL_MSG("No session passed in");
return NULL;

View File

@@ -24305,6 +24305,20 @@ static void test_wolfSSL_SESSION(void)
fdOpenSession(Task_self());
#endif
#if defined(SESSION_CERTS)
{
X509 *x509;
char buf[30];
int bufSz;
AssertNotNull(x509 = SSL_SESSION_get0_peer(sess));
AssertIntEQ((bufSz = X509_NAME_get_text_by_NID(
X509_get_subject_name(x509), NID_organizationalUnitName,
buf, sizeof(buf))), 7);
AssertIntEQ(XMEMCMP(buf, "Support", bufSz), 0);
}
#endif
AssertNotNull(sess_copy = wolfSSL_SESSION_dup(sess));
wolfSSL_SESSION_free(sess_copy);