Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request to web service over SSL

i am struggling to request web service using https. I am getting this kind of error:

An error occured : The certificate for this server is invalid. You might be connecting to a server that is pretending to be “SERVER_ADDRESS” which could put your confidential information at risk.

I am not using NSUrlConnectionDelegate. Here is my method:

- (void)sendRequestWithUrl:(NSURL*)url block:(void (^)(NSDictionary *dict, NSError *error)) block{
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];
    [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
    NSError* err = nil;
    NSHTTPURLResponse* rsp = nil;
    // Perform the request synchronously on this thread
    NSData *rspData = [NSURLConnection sendSynchronousRequest:request returningResponse:&rsp error:&err];
    if (rspData && err == nil) {
        NSDictionary *result = [NSJSONSerialization JSONObjectWithData:rspData options:NSJSONReadingMutableLeaves error:&err];
        if(result) {
            block(result, err);
        } else {
            block(nil, err);
        }
    }else{
        DLog(@"Requesting URL: %@  An error occured : %@",url,[err localizedDescription]);
        block(nil, err);
    }
}

How i could solve this problem ?

like image 370
Streetboy Avatar asked Feb 15 '13 09:02

Streetboy


People also ask

How do I request a certificate for webserver?

In Internet Explorer, connect to https://<servername>/certsrv, where <servername> is the host name of the computer running the CA Web Enrollment role service. Click Request a certificate. Click Advanced certificate request. Click Create and submit a certificate request to this CA.

What is SSL request?

SSL stands for Secure Sockets Layer and, in short, it's the standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.


1 Answers

Apple has a technote that covers this very well:

"Technical Note TN2232: HTTPS Server Trust Evaluation"

https://developer.apple.com/library/ios/#technotes/tn2232/_index.html

like image 174
quellish Avatar answered Sep 21 '22 08:09

quellish