I\'m trying to communicate with https server having self-signed certificate.
I can do this from .NET application (using ServicePointManager.ServerCertificateValidati
Piggybacking of @Santiago Jimenez Wilson's answer here.
Obviously patching react-native itself is pretty dirty so we took the suggested override and extracted it into a category.
Just create a new file called RCTHTTPRequestHandler+yourPatchName.m somewhere in your project:
//
// RCTHTTPRequestHandler+yourPatchName
//
#import "RCTBridgeModule.h"
#import "RCTHTTPRequestHandler.h"
@implementation RCTHTTPRequestHandler(yourPatchName)
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
@end
Next step would be to then differ between dev and prod and only overload the method for dev.