Skip to content

Commit 093f15c

Browse files
authored
Merge pull request #9496 from embhorn/zd20913
Enable wolfSSL_i2d_X509_NAME_canon to handle blank optional fields
2 parents 8c839b1 + 83f6fe1 commit 093f15c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/x509.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11630,15 +11630,20 @@ int wolfSSL_i2d_X509_NAME_canon(WOLFSSL_X509_NAME* name, unsigned char** out)
1163011630
}
1163111631
nameStr = (const char*)wolfSSL_ASN1_STRING_data(cano_data);
1163211632

11633-
ret = wc_EncodeNameCanonical(&names[i], nameStr, CTC_UTF8,
11634-
(byte)ConvertNIDToWolfSSL(entry->nid));
11635-
if (ret < 0) {
11636-
WC_FREE_VAR_EX(names, NULL, DYNAMIC_TYPE_TMP_BUFFER);
11637-
wolfSSL_ASN1_STRING_free(cano_data);
11638-
WOLFSSL_MSG("EncodeName failed");
11639-
return WOLFSSL_FATAL_ERROR;
11633+
/* allow for blank values in the name structure, eg OU= */
11634+
if (nameStr)
11635+
{
11636+
ret = wc_EncodeNameCanonical(&names[i], nameStr, CTC_UTF8,
11637+
(byte)ConvertNIDToWolfSSL(entry->nid));
11638+
if (ret < 0) {
11639+
WC_FREE_VAR_EX(names, NULL, DYNAMIC_TYPE_TMP_BUFFER);
11640+
wolfSSL_ASN1_STRING_free(cano_data);
11641+
WOLFSSL_MSG("EncodeName failed");
11642+
return WOLFSSL_FATAL_ERROR;
11643+
}
11644+
totalBytes += ret;
1164011645
}
11641-
totalBytes += ret;
11646+
1164211647
wolfSSL_ASN1_STRING_free(cano_data);
1164311648
}
1164411649
}

0 commit comments

Comments
 (0)