@@ -18,15 +18,17 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
1818 CFErrorRef errorRef;
1919 bool certificateEvaluationSucceeded = SecTrustEvaluateWithError (serverTrust, &errorRef);
2020 OSStatus status = SecTrustGetTrustResult (serverTrust, trustResult);
21- if (status != errSecSuccess)
22- {
23- certificateEvaluationSucceeded = false ;
24- NSString *errDescription = [NSString stringWithFormat: @" got status %d " , status];
25- *error = [[NSError alloc ] initWithDomain: @" com.datatheorem.trustkit" code: 1 userInfo: @{NSLocalizedDescriptionKey :errDescription}];
26- }
27- else if (!certificateEvaluationSucceeded && (error != NULL ))
28- {
29- *error = (__bridge_transfer NSError *)errorRef;
21+ if (error != NULL ) {
22+ if (status != errSecSuccess)
23+ {
24+ certificateEvaluationSucceeded = false ;
25+ NSString *errDescription = [NSString stringWithFormat: @" got status %d " , (int )status];
26+ *error = [[NSError alloc ] initWithDomain: @" com.datatheorem.trustkit" code: 1 userInfo: @{NSLocalizedDescriptionKey :errDescription}];
27+ }
28+ else if (!certificateEvaluationSucceeded)
29+ {
30+ *error = (__bridge_transfer NSError *)errorRef;
31+ }
3032 }
3133 }
3234 else
@@ -37,7 +39,7 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
3739 OSStatus status = SecTrustEvaluate (serverTrust, trustResult);
3840#pragma clang diagnostic pop
3941 if (status != errSecSuccess && (error != NULL )) {
40- NSString *errDescription = [NSString stringWithFormat: @" got status %d " , status];
42+ NSString *errDescription = [NSString stringWithFormat: @" got status %d " , ( int ) status];
4143 *error = [[NSError alloc ] initWithDomain: @" com.datatheorem.trustkit" code: 2 userInfo: @{NSLocalizedDescriptionKey :errDescription}];
4244 }
4345 }
0 commit comments