27374

how to ignore self-signing certificate with NSURLRequest

Question:

I need help with trying to bypass/ignor a self signing certificate.. I have looked everywhere and cannot find anything that has worked for me thus far..

I am trying to implements this <a href="http://www.jasonhooker.com/content/2010-02-15/how-allow-self-signed-certificates-when-using-nsurlrequest-your-iphone-app" rel="nofollow">here</a> however im not sure how to use this code

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

I add it to my app delegate but then I dont know what to do with it?

any help would be greatly appreciated..

currently I am not using anything because nothing has worked for me..

Answer1:

This is how I got it to work. I added these two methods just below the method where I call my connection to start.

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge]; }

Recommend

  • syntax error, unexpected $end in PHP, and I already checked '}'
  • Unit Test case using Rspec for each loop
  • Make mongoid session read only
  • Matlab to Python Conversion binary file read
  • Post comment to WordPress Blog from iPhone programmatically
  • iOS Date formatting
  • FragmentActivity with a Fragment Containing a MapView
  • IllegalArgumentException: The servlets named [HelloWorlds] and [Hello] are both mapped to the url-pa
  • Deployments not visible in Kubernetes Dashboard
  • Android NFC read Tags issue. Activity starts each time on data received
  • openssl handshake failed
  • How to resolve docker host names (/etc/hosts) in containers
  • Generate a unique string based on a pair of strings
  • Deleting a widget from QTableView
  • Adding independent aspx/asmx pages into DotNetNuke
  • Deduce parent class of inherited method in C++
  • What is this iOS exception with NSCFType?
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • Is there a parser equivalent of 'fragment' marking in ANTLR4?
  • xtable - background colour of added rows
  • how to solve invalid conversion specifier warning in iphone app
  • Find group of records that match multiple values
  • Hide HTML elements without javascript, only CSS
  • Center align outputs in ipython notebook
  • Build Successful but not running on simulator
  • Transactional Create with Validation in ServiceStack Redis Client
  • ActiveRecord query for a count of new users by day
  • Is calc() supported in html email?
  • req.body is undefined - nodejs
  • Symfony2: How to get request parameter
  • Akka Routing: Reply's send to router ends up as dead letters
  • Compare two NSDates in iPhone
  • Is there a mandatory requirement to switch app.yaml?
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • need help with bizarre java.net.HttpURLConnection behavior
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?