Last active
July 17, 2020 22:56
-
-
Save aleclarson/2bd4347a54d08d2abcbb96ebbb573070 to your computer and use it in GitHub Desktop.
Trust all SSL certificates in React Native (in development only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm | |
index 274f381..3b573dc 100644 | |
--- a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm | |
+++ b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm | |
@@ -108,6 +108,15 @@ - (void)cancelRequest:(NSURLSessionDataTask *)task | |
#pragma mark - NSURLSession delegate | |
+#if DEBUG | |
+- (void)URLSession:(NSURLSession *)session | |
+didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge | |
+ completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler | |
+{ | |
+ completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); | |
+} | |
+#endif | |
+ | |
- (void)URLSession:(NSURLSession *)session | |
task:(NSURLSessionTask *)task | |
didSendBodyData:(int64_t)bytesSent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment