本文介绍了iPhone FTPS客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何在iPhone上制作FTPS(FTP over SSL)。我想使用下面的代码:

  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];


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

这段代码连接到服务器,但不会一起说话。我也尝试使用以下来设置安全级别:

pre $ NS $ Dictionary $ {NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)kCFStreamSocketSecurityLevelSSLv3,kCFStreamSSLLevel,
kCFBooleanTrue,kCFStreamSSLAllowsAnyRoot,
kCFBooleanFalse,kCFStreamSSLValidatesCertificateChain,
主机名,kCFStreamSSLPeerName,
kCFBooleanFalse,kCFStreamSSLIsServer,
kCFBooleanFalse,kCFStreamSSLValidatesCertificateChain,
kCFBooleanTrue,kCFStreamSSLAllowsExpiredCertificates,
kCFBooleanTrue,kCFStreamSSLAllowsExpiredRoots,
nil];
CFWriteStreamSetProperty(ftpStream,kCFStreamPropertySSLSettings,settings);

这允许我连接和传输数据,但不通过SSL。



任何想法我做错了。

解决方案

iPhone上没有内置的FTPS功能,请参阅:



您必须建立自己的FTPS库。我也不知道iPhone上有任何第三方FTPS库 - 但上面的文章给出了一些概述&策略传输文件的可能性有多大。


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.

解决方案

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.

这篇关于iPhone FTPS客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 05:59