views:

26

answers:

1

I need a FTP TLS Connection for my iPhone-App. A normal FTP-Connection works fine. But I need also a secure TLS connection. I used the code from Apple´s SimpleFTPSample for the iPhone:

ftpStream = CFReadStreamCreateWithFTPURL(NULL, (CFURLRef) url);
self.networkStream = (NSInputStream *) ftpStream;

[self.networkStream retain];
self.networkStream.delegate = self;


CFReadStreamSetProperty((CFReadStreamRef)self.networkStream, kCFStreamPropertyFTPUserName, (CFStringRef)@"ftpuser");
CFReadStreamSetProperty((CFReadStreamRef)self.networkStream, kCFStreamPropertyFTPPassword, (CFStringRef)myFTPPassWord);


[self.networkStream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
[self.networkStream open];

This works fine for a normal FTP Connection.

But how do I setup a TLS Connection? I´m not sure what I need and if a TLS Connection works?

I tried some code:

NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:5];
[settings setObject:(NSString *)NSStreamSocketSecurityLevelTLSv1 forKey:(NSString *)kCFStreamSSLLevel];
[settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot];
CFReadStreamSetProperty((CFReadStreamRef)self.networkStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);

But without any success. Please can somebody help me. I need a FTP TLS Connection which is protected with a FTP Username and FTP Password.

Thanks!

A: 

When you say "FTP TLS" I assume you mean RFC 4217? I'm fairly certain that CFStream doesn't support that protocol. You'll have to build it up yourself. You may want to look at libcurl as a good solution. I've been reasonably happy with it for managing TFTP.

Rob Napier