fix for returning NULL when text not found and add test case

This commit is contained in:
Jacob Barthelmeh 2020-03-10 09:54:31 -06:00
parent 1035d73a05
commit 0be0cf44e4
2 changed files with 6 additions and 0 deletions

View File

@ -40715,6 +40715,7 @@ err:
nid = wolfSSL_OBJ_txt2nid(txt);
if (nid == NID_undef) {
WOLFSSL_MSG("Unable to find text");
ne = NULL;
}
else {
if (ne == NULL) {

View File

@ -24601,6 +24601,11 @@ static void test_wolfSSL_X509_NAME_ENTRY(void)
/* Test add entry by text */
AssertNotNull(entry = X509_NAME_ENTRY_create_by_txt(NULL, "commonName",
0x0c, cn, (int)sizeof(cn)));
#if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO) \
|| defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_NGINX)
AssertNull(X509_NAME_ENTRY_create_by_txt(&entry, "unknown",
V_ASN1_UTF8STRING, cn, (int)sizeof(cn)));
#endif
AssertIntEQ(X509_NAME_add_entry(nm, entry, -1, 0), SSL_SUCCESS);
X509_NAME_ENTRY_free(entry);