How to open HTTPS webservice in iPhone browser programmatically /

How to open HTTPS web service in iPhone browser programmatically ? I think we can open the browser with the syntax below only for the HTTP URL,

 NSURL *url = [NSURL URLWithString:@"http://www.iphonedevelopertips.com"];
[[UIApplication sharedApplication] openURL:url]; 

Is it possible to use the same syntax to open it for HTTPS url? when I tried, he stopped the application, stating that "Service Untrusted Certificate" ... How do I continue to access the HTTPS web service ??? Please help me

Thank.

+3
source share
1 answer

You can do this by overriding allowAnyHTTPSCertificateForHost: in the NSURLRequest class:

@implementation NSURLRequest(NSHTTPURLRequest)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
    return YES; 
}
@end

ugly but working.

+1
source

Source: https://habr.com/ru/post/1762404/


All Articles