Skip to content

Commit

Permalink
Remove the conditional code and just leave the result.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvl committed Sep 26, 2024
1 parent fb798c3 commit 3d79b15
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions Sources/Core/GTMSessionFetcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@
#define GTM_TARGET_SUPPORTS_APP_TRANSPORT_SECURITY 1
#endif

#define GTM_SDK_REQUIRES_TLSMINIMUMSUPPORTEDPROTOCOLVERSION 1
#define GTM_SDK_SUPPORTS_TLSMINIMUMSUPPORTEDPROTOCOLVERSION 1
#define GTM_SDK_REQUIRES_SECTRUSTEVALUATEWITHERROR 1

#if __has_attribute(swift_async)
// Once Clang 13/Xcode 13 can be assumed, can switch to NS_SWIFT_DISABLE_ASYNC.
#define GTM_SWIFT_DISABLE_ASYNC __attribute__((swift_async(none)))
Expand Down Expand Up @@ -950,17 +946,7 @@ - (NSURLSession *)createSessionWithDelegate:(id<NSURLSessionDelegate>)sessionDel
_configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
}
#if !GTM_ALLOW_INSECURE_REQUESTS
#if GTM_SDK_REQUIRES_TLSMINIMUMSUPPORTEDPROTOCOLVERSION
_configuration.TLSMinimumSupportedProtocolVersion = tls_protocol_version_TLSv12;
#elif GTM_SDK_SUPPORTS_TLSMINIMUMSUPPORTEDPROTOCOLVERSION
if (@available(iOS 13, tvOS 13, macOS 10.15, *)) {
_configuration.TLSMinimumSupportedProtocolVersion = tls_protocol_version_TLSv12;
} else {
_configuration.TLSMinimumSupportedProtocol = kTLSProtocol12;
}
#else
_configuration.TLSMinimumSupportedProtocol = kTLSProtocol12;
#endif // GTM_SDK_REQUIRES_TLSMINIMUMSUPPORTEDPROTOCOLVERSION
#endif
} // !_configuration
_configuration.HTTPCookieStorage = self.cookieStorage;
Expand Down Expand Up @@ -2579,7 +2565,6 @@ + (void)evaluateServerTrust:(SecTrustRef)serverTrust
// so it may be redundant for us to also lock, but it's easy to synchronize here
// anyway.
BOOL shouldAllow;
#if GTM_SDK_REQUIRES_SECTRUSTEVALUATEWITHERROR
CFErrorRef errorRef = NULL;
@synchronized([GTMSessionFetcher class]) {
GTMSessionMonitorSynchronized([GTMSessionFetcher class]);
Expand All @@ -2594,32 +2579,6 @@ + (void)evaluateServerTrust:(SecTrustRef)serverTrust
request);
CFRelease(errorRef);
}
#else
SecTrustResultType trustEval = kSecTrustResultInvalid;
OSStatus trustError;
@synchronized([GTMSessionFetcher class]) {
GTMSessionMonitorSynchronized([GTMSessionFetcher class]);

trustError = SecTrustEvaluate(serverTrust, &trustEval);
}
if (trustError != errSecSuccess) {
GTMSESSION_LOG_DEBUG(@"Error %d evaluating trust for %@",
(int)trustError, request);
shouldAllow = NO;
} else {
// Having a trust level "unspecified" by the user is the usual result, described at
// https://developer.apple.com/library/mac/qa/qa1360
if (trustEval == kSecTrustResultUnspecified
|| trustEval == kSecTrustResultProceed) {
shouldAllow = YES;
} else {
shouldAllow = NO;
GTMSESSION_LOG_DEBUG(@"Challenge SecTrustResultType %u for %@, properties: %@",
trustEval, request.URL.host,
CFBridgingRelease(SecTrustCopyProperties(serverTrust)));
}
}
#endif // GTM_SDK_REQUIRES_SECTRUSTEVALUATEWITHERROR
handler(serverTrust, shouldAllow);

CFRelease(serverTrust);
Expand Down

0 comments on commit 3d79b15

Please sign in to comment.