@@ -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
0 commit comments