Does NSStream's SSL or TLS support work?
Does NSStream's SSL or TLS support work?
- Subject: Does NSStream's SSL or TLS support work?
- From: Eric Scharff <email@hidden>
- Date: Mon, 25 Feb 2008 09:51:28 -0800 (PST)
I am writing an application where encrypted communication is essential. I have used the non-blocking-esque NSStream libraries for non-encrypted data in applications before, and I'd really like to use NSStream to encrypt transport with TLS (or SSL).
Unfortunately, no matter how I set up the connection, I get error codes. Even if I connect to a site who I know has a valid certificate (www.apple.com port 443), I get the error code NSUnknownErrorDomain error -9843. sent to my callback. This error seems to correspond to errSSLHostNameMismatch in SecureTransport.h (peer host name mismatch). This doesn't make sense because TLS shouldn't require host name verification anyway, and I'm sure that the server's SSL certificate is valid.
Has anyone successfully used NSStream to talk SSL? I'd really like to use this non-blocking API rather than relying, for example, on a blocking OpenSSL based API.
My initialization code is below:
[NSStream getStreamsToHost: [NSHost hostWithName: [serverName stringValue]] port: [serverPort intValue] inputStream: &fileInStream outputStream: &fileOutStream];
if ((fileInStream != nil) && (fileOutStream != nil)) {
[fileInStream retain];
[fileOutStream retain];
[fileInStream setProperty: NSStreamSocketSecurityLevelTLSv1 forKey: NSStreamSocketSecurityLevelKey];
[fileOutStream setProperty: NSStreamSocketSecurityLevelTLSv1 forKey: NSStreamSocketSecurityLevelKey];
// [fileInStream setProperty: NSStreamSocketSecurityLevelNegotiatedSSL forKey: NSStreamSocketSecurityLevelKey];
// [fileOutStream setProperty: NSStreamSocketSecurityLevelNegotiatedSSL forKey: NSStreamSocketSecurityLevelKey];
[fileInStream setDelegate: self];
[fileOutStream setDelegate: self];
[fileInStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode];
[fileOutStream scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode];
[fileInStream open];
[fileOutStream open];
}
Any help would be GREATLY appreciated.
Thanks,
-Eric
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden