我不知道如何在iPhone上製作FTPS(FTP over SSL)。我想使用下面的代碼iPhone FTPS客戶端
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");
}
此代碼連接到服務器,但然後停止在一起說話。我也嘗試使用以下設置安全級別
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);
這使我可以連接和傳輸數據,但不通過SSL。
任何想法我做錯了什麼。