@@ -18,15 +18,17 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
18
18
CFErrorRef errorRef;
19
19
bool certificateEvaluationSucceeded = SecTrustEvaluateWithError (serverTrust, &errorRef);
20
20
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
+ }
30
32
}
31
33
}
32
34
else
@@ -37,7 +39,7 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
37
39
OSStatus status = SecTrustEvaluate (serverTrust, trustResult);
38
40
#pragma clang diagnostic pop
39
41
if (status != errSecSuccess && (error != NULL )) {
40
- NSString *errDescription = [NSString stringWithFormat: @" got status %d " , status];
42
+ NSString *errDescription = [NSString stringWithFormat: @" got status %d " , ( int ) status];
41
43
*error = [[NSError alloc ] initWithDomain: @" com.datatheorem.trustkit" code: 2 userInfo: @{NSLocalizedDescriptionKey :errDescription}];
42
44
}
43
45
}
0 commit comments