iPhone FTPS client

孤街醉人 提交于 2019-12-10 11:58:43

问题


I have no clue how to make an FTPS (FTP over SSL) on the iPhone. I would like to use the following code

ftpStream = CFWriteStreamCreateWithFTPURL(NULL, (CFURLRef) url);
CFWriteStreamSetProperty(ftpStream, kCFStreamPropertyFTPUserName,username);
CFWriteStreamSetProperty(ftpStream, kCFStreamPropertyFTPPassword,password);

self.networkStream = (NSOutputStream *) ftpStream;      
[self.networkStream setProperty:NSStreamSocketSecurityLevelSSLv3 forKey:(id)NSStreamSocketSecurityLevelKey];

self.networkStream.delegate = self;
[self.networkStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.networkStream open];

...

- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode
{
  NSLog(@"Hello\n");
}

This code connects to the server but then stops talking all together. I have also tried using the following to set the security level

NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
    (NSString *)kCFStreamSocketSecurityLevelSSLv3, kCFStreamSSLLevel,
    kCFBooleanTrue, kCFStreamSSLAllowsAnyRoot,
    kCFBooleanFalse, kCFStreamSSLValidatesCertificateChain,
    hostName, kCFStreamSSLPeerName,
    kCFBooleanFalse, kCFStreamSSLIsServer,
    kCFBooleanFalse,kCFStreamSSLValidatesCertificateChain,
    kCFBooleanTrue, kCFStreamSSLAllowsExpiredCertificates,
    kCFBooleanTrue, kCFStreamSSLAllowsExpiredRoots,
    nil];
CFWriteStreamSetProperty(ftpStream, kCFStreamPropertySSLSettings, settings);

This allows me to connect and transfer data but not through SSL.

Any idea what I am doing wrong.


回答1:


There are no built-in FTPS capabilities on the iPhone see: http://developer.apple.com/iphone/library/technotes/tn2009/tn2152.html

You have to build your own FTPS library. I'm also not aware of any third-party FTPS library for the iPhone - but the article above gives some overview & strategies what possibilities for transferring files are available.




回答2:


You should check this example, is from the iOS Developer Library, it's called SimpleFTPSample the description says:

SimpleFTPSample shows how to do simple FTP operations using the NSURLConnection and CFFTPStream APIs. It can download a file using both NSURLConnection and CFFTPStream. Also, it can upload a file, list a directory, and create a directory using CFFTPStream.

Hope this helps you.




回答3:


The above answers are correct: you got to do it on your own our purchase it from Chilkat Software.



来源:https://stackoverflow.com/questions/1899343/iphone-ftps-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!