1

Ok, so this question has multiple technologies that can play into my question so here it goes.

On my server side, I have a Node JS script running with a basic TLS server (Including a certificate and key from VeriSign) Like the following:

var tls = require('tls');
var fs = require('fs');

var options = {
  pfx: fs.readFileSync('serverkeys.pfx'),
  passphrase: "sample-passphrase"
};

var server = tls.createServer(options, function(stream) {
  stream.setEncoding('utf8');
  stream.write("welcome!\n");
  stream.end();
});

server.listen(8000, function() {
  console.log('server bound');
});

I am able to access this server from chrome outside of the server's network.

On my iOS app I have the following code to access the server:

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithURL:[NSURL URLWithString:@"https://serverurl:8000"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {              
  NSLog(@"Completed: %@", error);
}];        
[task resume];

That code works great when I use

https://serverurl:443

to access my IIS webserver, but when I want to use the

https://serverurl:8000

it gives me the following error:

Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed."

So I can't figure out why it loads on a web browser but not in the nsurlsession which works fine with my ssl certificate.

Any properties that need to be set for accessing the node js server over tls properly?

Micaiah Wallace
  • 1,101
  • 10
  • 17

1 Answers1

0

This is an old post, but to finish it off generalhenry was right.

It was easier to use the HTTPS library rather than the TLS library in order for my Objective-c code to the server by nsurlsession.

Micaiah Wallace
  • 1,101
  • 10
  • 17