• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with NSStream SSL Connection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with NSStream SSL Connection


  • Subject: Re: Problem with NSStream SSL Connection
  • From: Ramesh P <email@hidden>
  • Date: Mon, 9 Nov 2009 19:29:37 +0530

Hi fred,
Thanks for your quick reply.
I am using the same server for Dot net application developed for windows OS and Cocoa application developed for Mac OS.  It works fine in the windows application. Problem with the Cocoa application only. Any ideas regarding this? How can I solve this?

Thanks,
Ramesh.P


On Mon, Nov 9, 2009 at 6:35 PM, Frederick Cheung <email@hidden> wrote:

On 9 Nov 2009, at 12:47, Ramesh P wrote:

Hi all,
I am using NSStream with SSL property for socket connection. It works fine when I use the local IP address such as 192.168.1.77. But if I use any server like www.xyz.com (it has SecurityLevelTLSv1), it shows an error
error code:-9843, Message:Operation could not be completed. (NSUnknownErrorDomain error -9843.)


Given the subject matter that error is coming out of SecureTransport, and in there you have:

       /* more errors detected by us */
       errSSLHostNameMismatch          = -9843,        /* peer host name mismatch */

ie the name on the certificate doesn't match the host name you used to connect to it.

Fred

Here is my code:

NSURL *website = [NSURL URLWithString:@"www.xyz.com"];
   NSHost *host = [NSHost hostWithName:[website host]];
   if(host) {
       NSLog(@"Valid host");
       [NSStream getStreamsToHost:host port:443 inputStream:&iStream outputStream:&oStream] ;
       [self openStream];
   }.

-(void)openStream{
NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:1];
   [settings setObject:(NSString *)NSStreamSocketSecurityLevelTLSv1 forKey:(NSString *)kCFStreamSSLLevel];
   [settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];

   [iStream retain];
   [iStream setDelegate:self];
   [iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
   CFReadStreamSetProperty((CFReadStreamRef)iStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
   //[iStream setProperty:NSStreamSocketSecurityLevelTLSv1 forKey:NSStreamSocketSecurityLevelKey];
   [iStream open];

   [oStream retain];
   [oStream setDelegate:self];
   [oStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
   CFWriteStreamSetProperty((CFWriteStreamRef)oStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
   //[oStream setProperty:NSStreamSocketSecurityLevelTLSv1 forKey:NSStreamSocketSecurityLevelKey];
   [oStream open];
}

I tried using both NSStream  and CFStream. I am getting the same error in both cases.

NSStreamEventOpenCompleted and NSStreamEventErrorOccurred events are called.

Please help me in this.

Thanks in advance.

Ramesh.P
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem with NSStream SSL Connection
      • From: Jens Alfke <email@hidden>
References: 
 >Problem with NSStream SSL Connection (From: Ramesh P <email@hidden>)
 >Re: Problem with NSStream SSL Connection (From: Frederick Cheung <email@hidden>)

  • Prev by Date: Re: Problem with NSStream SSL Connection
  • Next by Date: Re: Problem with NSStream SSL Connection
  • Previous by thread: Re: Problem with NSStream SSL Connection
  • Next by thread: Re: Problem with NSStream SSL Connection
  • Index(es):
    • Date
    • Thread