Skip to content

Commit 13d6984

Browse files
committed
Fix serial-0 test: add Apple native cert guard, fix memory leak, assert specific error code
1 parent 8b5bde4 commit 13d6984

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/api/test_asn.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ int test_SerialNumber0_RootCA(void)
926926
EXPECT_DECLS;
927927

928928
#if !defined(NO_CERTS) && !defined(NO_FILESYSTEM) && !defined(NO_RSA) && \
929-
!defined(WOLFSSL_NO_PEM) && defined(WOLFSSL_PEM_TO_DER)
929+
!defined(WOLFSSL_NO_PEM) && defined(WOLFSSL_PEM_TO_DER) && \
930+
!defined(WOLFSSL_TEST_APPLE_NATIVE_CERT_VALIDATION)
930931
/* Test that root CA certificates with serial number 0 are accepted,
931932
* while non-root certificates with serial 0 are rejected (issue #8615) */
932933

@@ -983,10 +984,15 @@ int test_SerialNumber0_RootCA(void)
983984
}
984985
#endif
985986

987+
if (cm != NULL) {
988+
wolfSSL_CertManagerFree(cm);
989+
cm = NULL;
990+
}
991+
986992
/* Test 5: Self-signed non-CA certificate with serial 0 should be rejected */
987993
ExpectNotNull(cm = wolfSSL_CertManagerNew());
988-
ExpectIntNE(wolfSSL_CertManagerLoadCA(cm, selfSignedNonCASerial0File, NULL),
989-
WOLFSSL_SUCCESS);
994+
ExpectIntEQ(wolfSSL_CertManagerLoadCA(cm, selfSignedNonCASerial0File, NULL),
995+
WC_NO_ERR_TRACE(ASN_PARSE_E));
990996

991997
if (cm != NULL) {
992998
wolfSSL_CertManagerFree(cm);

0 commit comments

Comments
 (0)