【发布时间】:2014-07-28 19:12:08
【问题描述】:
我正在尝试禁用一些密码(弱),例如单 DES、单 DES 40 位等。
我尝试使用来自How does one set SSL ciphers when using CFSocket/CFStream in Cocoa? 和邮件列表消息CFNetwork SSL and long blocking delays 的这段代码,但我需要访问套接字数据才能获得CFDataRef。
这是我尝试在AFURLConnectionOperation 类的握手方法中插入的代码:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge (NSURLAuthenticationChallenge *)challenge{
CFReadStreamRef stream = [sock getCFReadStream];
CFDataRef data = CFReadStreamCopyProperty(stream, kCFStreamPropertySocketSSLContext);
// Extract the SSLContextRef from the CFData
SSLContextRef sslContext;
CFDataGetBytes(data, CFRangeMake(0, sizeof(SSLContextRef)), &sslContext);
// Get all enabled ciphers
size_t numCiphers;
SSLGetNumberEnabledCiphers(sslContext,&numCiphers);
SSLCipherSuite ciphers[numCiphers];
SSLGetEnabledCiphers(sslContext,ciphers,&numCiphers);
// Create a new cipher array with only non-DH ciphers, and set it
SSLCipherSuite finalCiphers[numCiphers];
int numFinalCiphers = 0;
for(int i=0; i<numCiphers; i++) {
SSLCipherSuite suite = ciphers[i];
if(!cipherSuiteUsesDH(suite)) {
finalCiphers[numFinalCiphers] = suite;
numFinalCiphers++;
}
}
SSLSetEnabledCiphers(sslContext,finalCiphers,numFinalCiphers);
}
我们将不胜感激。
编辑:不幸的是,这是一个现有项目,它仍然使用 AFNetworking 版本 1。
【问题讨论】:
-
另见Securing iOS Applications。看起来很有趣。
-
您好,感谢您的回复,我认为它们是不同级别的 Api,希望在某处可能有一座桥梁。我已经浏览了视频,但我希望能找到示例代码。有没有其他方法可以禁用密码?
-
我正在尝试做同样的事情。到目前为止,我已经找到了一种方法来做到这一点twitter.com/abelenko/status/437266477436002304gist.github.com/belenko/d9c29ffbf2dca8a3dd0c,但这是使用私有 API,正如 cmets 中所说的那样,它会导致 App Store 中的应用被拒绝。
标签: ios iphone ssl afnetworking cfnetwork