Skip to content

Commit d3b30f8

Browse files
committed
Check underlying error, want only maximum validity period error
add apple test macros to tests requiring cert manager
1 parent 877bade commit d3b30f8

2 files changed

Lines changed: 56 additions & 4 deletions

File tree

src/internal.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42857,6 +42857,46 @@ static int DisplaySecTrustError(CFErrorRef error, SecTrustRef trust)
4285742857
return 0;
4285842858
}
4285942859

42860+
static int MaxValidityPeriodErrorOnly(CFErrorRef error)
42861+
{
42862+
int multiple = 0;
42863+
42864+
CFDictionaryRef userInfo = CFErrorCopyUserInfo(error);
42865+
if (userInfo) {
42866+
/* Get underlying error */
42867+
CFTypeRef underlying =
42868+
CFDictionaryGetValue(userInfo, kCFErrorUnderlyingErrorKey);
42869+
if (underlying) {
42870+
/* Get underlying error value*/
42871+
CFDictionaryRef underlyingDict =
42872+
CFErrorCopyUserInfo((CFErrorRef)underlying);
42873+
if (underlyingDict) {
42874+
char buffer[512];
42875+
CFStringRef values =
42876+
CFDictionaryGetValue(underlyingDict,
42877+
kCFErrorLocalizedDescriptionKey);
42878+
if(CFStringGetCString(values, buffer, sizeof(buffer),
42879+
kCFStringEncodingUTF8)) {
42880+
if (XSTRSTR(buffer, "Certificate exceeds maximum "
42881+
"temporal validity period") &&
42882+
(!XSTRSTR(buffer, "Certificate exceeds maximum "
42883+
"temporal validity period,") ||
42884+
!XSTRSTR(buffer, ", Certificate exceeds maximum "
42885+
"temporal validity period"))) {
42886+
WOLFSSL_MSG("Maximum validity period error only");
42887+
} else {
42888+
WOLFSSL_MSG("Found other errors");
42889+
multiple = 1;
42890+
}
42891+
}
42892+
CFRelease(underlyingDict);
42893+
}
42894+
}
42895+
CFRelease(userInfo);
42896+
}
42897+
return multiple;
42898+
}
42899+
4286042900
/*
4286142901
* Validates a chain of certificates using the Apple system trust APIs
4286242902
*
@@ -42966,8 +43006,14 @@ static int DoAppleNativeCertValidation(WOLFSSL* ssl,
4296643006
* (See: https://support.apple.com/en-us/103769)
4296743007
* therefore we should skip over this particular error */
4296843008
if (code == errSecCertificateValidityPeriodTooLong) {
42969-
WOLFSSL_MSG("Skipping certificate validity period error");
42970-
ret = 1;
43009+
if (MaxValidityPeriodErrorOnly(error)) {
43010+
WOLFSSL_MSG("Multiple reasons for validity period error, "
43011+
"not skipping");
43012+
ret = 0;
43013+
} else {
43014+
WOLFSSL_MSG("Skipping certificate validity period error");
43015+
ret = 1;
43016+
}
4297143017
/* TODO: ensure other errors aren't masked by this error */
4297243018
}
4297343019
#endif

tests/api.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,6 +5039,7 @@ static int test_wolfSSL_OtherName(void)
50395039
}
50405040

50415041
#ifdef HAVE_CERT_CHAIN_VALIDATION
5042+
#ifndef WOLFSSL_TEST_APPLE_NATIVE_CERT_VALIDATION
50425043
static int test_wolfSSL_CertRsaPss(void)
50435044
{
50445045
EXPECT_DECLS;
@@ -5097,7 +5098,7 @@ static int test_wolfSSL_CertRsaPss(void)
50975098
return EXPECT_RESULT();
50985099
}
50995100
#endif
5100-
5101+
#endif
51015102
static int test_wolfSSL_CTX_load_verify_locations_ex(void)
51025103
{
51035104
EXPECT_DECLS;
@@ -48425,6 +48426,7 @@ static int verify_sig_cm(const char* ca, byte* cert_buf, size_t cert_sz,
4842548426
#endif
4842648427

4842748428
#if !defined(NO_FILESYSTEM)
48429+
#ifndef WOLFSSL_TEST_APPLE_NATIVE_CERT_VALIDATION
4842848430
static int test_RsaSigFailure_cm(void)
4842948431
{
4843048432
EXPECT_DECLS;
@@ -48499,7 +48501,7 @@ static int test_EccSigFailure_cm(void)
4849948501
#endif /* HAVE_ECC */
4850048502
return EXPECT_RESULT();
4850148503
}
48502-
48504+
#endif
4850348505
#endif /* !NO_FILESYSTEM */
4850448506
#endif /* NO_CERTS */
4850548507

@@ -58104,6 +58106,7 @@ static int test_chainJ(WOLFSSL_CERT_MANAGER* cm)
5810458106
return ret;
5810558107
}
5810658108

58109+
#ifndef WOLFSSL_TEST_APPLE_NATIVE_CERT_VALIDATION
5810758110
static int test_various_pathlen_chains(void)
5810858111
{
5810958112
EXPECT_DECLS;
@@ -58162,6 +58165,7 @@ static int test_various_pathlen_chains(void)
5816258165

5816358166
return EXPECT_RESULT();
5816458167
}
58168+
#endif
5816558169
#endif /* !NO_RSA && !NO_SHA && !NO_FILESYSTEM && !NO_CERTS */
5816658170

5816758171
#if defined(HAVE_KEYING_MATERIAL) && defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES)
@@ -67013,6 +67017,7 @@ static int test_tls_cert_store_unchanged_ssl_ready(WOLFSSL* ssl)
6701367017
}
6701467018
#endif
6701567019

67020+
#ifndef WOLFSSL_TEST_NATIVE_CERT_VALIDATION
6701667021
static int test_tls_cert_store_unchanged(void)
6701767022
{
6701867023
EXPECT_DECLS;
@@ -67069,6 +67074,7 @@ static int test_tls_cert_store_unchanged(void)
6706967074
#endif
6707067075
return EXPECT_RESULT();
6707167076
}
67077+
#endif
6707267078

6707367079
static int test_wolfSSL_SendUserCanceled(void)
6707467080
{

0 commit comments

Comments
 (0)