-4
- (IBAction)loginAction:(id)sender {
    NSString *post =[NSString stringWithFormat:@"Email=%@&Password=%@",self.eMail.text,self.password.text];
    NSString * loginURL = @"http://75.101.159.160:8222/api/mobileappapi/user/login"; // Login URL

    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSHTTPURLResponse   * response;
    NSError             * error;
    NSMutableURLRequest * request;
    request = [[NSMutableURLRequest alloc]initWithURL:nil cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0];
    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
    [request setHTTPBody:postData];
    request.URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",loginURL]];
    error       = nil;
    response    = nil;
    NSData* jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

   // jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:response error:&error];


    NSDictionary* resultsDictionary = [NSJSONSerialization JSONObjectWithData:jsonUpdateDate options:0 error:&error];
    NSLog(@"%@",resultsDictionary);


    NSString *userRole = [resultsDictionary objectForKey:@"UserRole"];
    if (userRole != (NSString*)[NSNull null]) {
    if ([userRole isEqualToString:@"Passenger"]) {
        // SuccessuserRole
        HomeScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeScreen"];
        [self presentViewController:obj animated:NO completion:nil];
    }
    else if ([userRole isEqualToString:@"Driver"]){

        SelectVehicle *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"SelectVehicle"];
        [self presentViewController:obj animated:NO completion:nil];

        }
    }
}

I can not access the service here

Cœur
  • 37,241
  • 25
  • 195
  • 267
vshnu
  • 5
  • 8

1 Answers1

1

See Apple’s Info.plist reference for full details (thanks @gnasher729).

You can add exceptions for specific domains in your Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>testdomain.com</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.2</string>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <false/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.2</string>
            <key>NSRequiresCertificateTransparency</key>
            <false/>
        </dict>
    </dict>
</dict>

All the keys for each excepted domain are optional. The speaker did not elaborate on any of the keys, but I think they’re all reasonably obvious.

(Source: WWDC 2015 session 703, “Privacy and Your App”, 30:18)

You can also ignore all app transport security restrictions with a single key, if your app has a good reason to do so:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

If your app does not have a good reason, you may risk rejection:

Setting NSAllowsArbitraryLoads to true will allow it to work, but Apple was very clear in that they intend to reject apps who use this flag without a specific reason. The main reason to use NSAllowsArbitraryLoads I can think of would be user created content (link sharing, custom web browser, etc). And in this case, Apple still expects you to include exceptions that enforce the ATS for the URLs you are in control of.

If you do need access to specific URLs that are not served over TLS 1.2, you need to write specific exceptions for those domains, not use NSAllowsArbitraryLoads set to yes. You can find more info in the NSURLSesssion WWDC session.

Please be careful in sharing the NSAllowsArbitraryLoads solution. It is not the recommended fix from Apple. — kcharwood (thanks @marco-tolman)

Courtesy : https://stackoverflow.com/a/30732693/2963912

Community
  • 1
  • 1
techloverr
  • 2,597
  • 1
  • 16
  • 28