每次SSL握手都失败了:
– CFNetwork SSLHandshake失败(-9824 – > -9829)
– CFNetwork SSLHandshake失败(-9807)
这是我使用的一种方法:
CFReadStreamRef readStream;CFWriteStreamRef writeStream;CFStreamCreatePairWithSocketToHost(NulL,(CFStringRef)@"my-server-name",1234,&readStream,&writeStream);//------------------------------------------------------// Set props.//CFReadStreamSetProperty(readStream,kcfStreamPropertySocketSecurityLevel,kcfStreamSocketSecurityLevelNegotiatedSSL);CFReadStreamSetProperty(readStream,kcfStreamSSLAllowsExpiredCertificates,kcfBooleanTrue);CFReadStreamSetProperty(readStream,kcfStreamSSLAllowsExpiredRoots,kcfStreamSSLAllowsAnyRoot,kcfStreamSSLValIDatesCertificateChain,kcfBooleanFalse);CFReadStreamSetProperty(readStream,kcfStreamSSLPeername,kcfNull);CFWriteStreamSetProperty(writeStream,kcfStreamSocketSecurityLevelNegotiatedSSL);CFWriteStreamSetProperty(writeStream,kcfBooleanTrue);CFWriteStreamSetProperty(writeStream,kcfBooleanFalse);CFWriteStreamSetProperty(writeStream,kcfNull);//------------------------------------------------------// Open streams.//if(!CFReadStreamOpen(readStream)){ NSLog(@"CFReadStreamOpen Failed!"); return 0;}if(!CFWriteStreamOpen(writeStream)){ NSLog(@"CFWriteStreamOpen Failed!"); CFReadStreamClose(readStream); return 0;}//------------------------------------------------------// Send some data.//UInt8 data[20] = {0};*(ushort*)data = 18;for(int i = 2; i < 20; i++){ data[i] = 'A' + i;}NSLog(@"Sending some data...");CFIndex bytesSent = CFWriteStreamWrite(writeStream,data,20);NSLog(@"Bytes Sent: %d",(int)bytesSent);//------------------------------------------------------// Close streams.//CFReadStreamClose(readStream);CFWriteStreamClose(writeStream);
我也尝试使用SecureTransport(SSLCreateContext,SSLSetConnection,SSLHandshake,它是相同的 – SSL握手失败.
任何建议都非常感谢.
解决方法 错误有很多可能的原因.您应该首先使用Mac上的curl命令来访问Erlang服务器. Curl会为您提供更多描述性错误.您需要传递-k标志以告知它忽略证书错误.一些快速的可能性:您的Objective-C代码是否设置为允许无效的证书?是否设置为验证域名,并且您的开发设置不执行反向DNS?
总结以上是内存溢出为你收集整理的iOS和Erlang – 使用自签名证书的SSL握手失败全部内容,希望文章能够帮你解决iOS和Erlang – 使用自签名证书的SSL握手失败所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)