0

I'm developing a simple application for the iPhone which makes a post request with https protocol. This is the piece of code:

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:@"https://serverapp:8443/webapps"];
[urlRequest setHTTPMethod:@"POST"];
NSError *error = nil;
[NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:&error]; 

and I have this error:

Error happened = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “serverapp” which could put your confidential information at risk.

How can I import the certificate into my project?


Thank you for the responses, but I don't want to bypass the certificate, but I want to communicate with the server with a valid certificate that I have. It is possible to do this?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
user2971911
  • 151
  • 1
  • 4
  • Check this : **http://stackoverflow.com/questions/18415157/error-domain-nsurlerrordomain-code-1202-iphone** – Kumar KL Mar 07 '14 at 13:00

2 Answers2

0

This happens from time-to-time and indicates a problem at the App Store end. It usually clears itself if you wait.

If you don;t want to wait you can try the many solutions that have beed proposed over time. Some work for wome people some time.

The first thing that comes up is do you have any anti-virus software running? If so disable it reboot and try the App store.

Some have had success going to /var/folders and deleting all the content in there. Its cache files and such. Then restart the Mac.

neither of those work have a look at the more like this box on the roght side of this page or google

NSURLErrorDomain error 1012

(notice I remved the minus from the error number. If you leave it there Google will think you are looking for everything but 1012)

credit to https://discussions.apple.com/message/22747644#22747644

https://discussions.apple.com/thread/5375125

codercat
  • 22,873
  • 9
  • 61
  • 85
0

its not possible to do synchronous connection for https url.

You need to use asynchronous connection because you will require to use an certificate which wil be asked in the delegate methods

#pragma mark NSURLConnection Delegate Methods

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace: (NSURLProtectionSpace *)protectionSpace;

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
Fran Martin
  • 2,369
  • 22
  • 19