How to ignore SSL certificate issue in the WebView in IOS
Posted By : Siddharth Dixit | 28-Dec-2014
In this blog, I would like to tell how to remove such type of error if it is encountered by you when you pass the desired URl (for e.g http://www.yahoo.com) in the url property of the webView.
For this particular issue if it arises,you have to modify the files in the SDK directory.Look for the TiUIWebView.m which you'll find in your SDK directory such as /Library/ApplicationSupport/Titanium/mobilesdk/osx/1.7.1/iphone/Classes/TiUIWebView.m
Now above this particular code
@implementation TiUIWebView
You should paste this code
@interface NSURLRequest (DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
@end
This just sorts out a warning AFAIK. Then you have to modify the code here
-(void)setUrl_:(id)args
Look for this and modify it like this
if ([self isURLRemote])
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
// Use the private method setAllowsAnyHTTPSCertificate:forHost:
// to not validate the HTTPS certificate.
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
[self loadURLRequest:request];
if (scalingOverride==NO)
{
[[self webview] setScalesPageToFit:YES];
}
}
After copying and modifying the required code in TiUIWebView.m .do a complete rebuild of the required code in order to ignore the SSL certificate issue in a WebView of titanium.After that pass any URL the error would not come.
var webView = Ti.UI.createWebView({
url:”http://www.yahoo.com”
});
win.add(webView);
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Siddharth Dixit
Siddharth is an iPhone and Android application developer with experience in Titanium Framework .