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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to