iOS:遇到错误 kCFURLErrorUserCancelledAuthentication -1012?
<p><p>在 iOS 应用程序中需要签署一个之前已获得的证书请求。当我尝试运行查询时捕获此错误:</p>
<blockquote>
<p>kCFURLErrorUserCancelledAuthentication -1012.</p>
</blockquote>
<p>文档说:</p>
<blockquote>
<p>kCFURLErrorUserCancelledAuthentication The connection failed because
the user cancelled required authentication.</p>
</blockquote>
<p>实现如下:</p>
<pre><code>- (void)startConnection {
NSString *serverURL = @"host.ru/method";
MKNetworkEngine *engine = [ initWithHostName:serverURL customHeaderFields:nil];
MKNetworkOperation *op = ;
NSString *thePath = [ pathForResource:@"client" ofType:@"p12"];
;
op.clientCertificate = thePath;
op.clientCertificatePassword = @"1234qwerty";
[op addCompletionHandler:^(MKNetworkOperation *operation) {
NSLog(@"-->>%@", );
}errorHandler:^(MKNetworkOperation *errorOp, NSError* err) {
NSLog(@"MKNetwork request error : %@", );
}];
;
}
</code></pre>
<p>我做错了什么?</p>
<p>附言</p>
<p>Certificate,即尝试签名请求已提前收到。在浏览器中单独测试,没问题。</p>
<p>一个应用程序对同一服务器的请求通常是相同的方案。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>当您的连接发送身份验证质询请求时,可能会发生这种情况。</p>
<p>可能的原因是网站的证书无效/不受信任,而您选择不接受无效证书。</p></p>
<p style="font-size: 20px;">关于iOS:遇到错误 kCFURLErrorUserCancelledAuthentication -1012?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24785539/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24785539/
</a>
</p>
页:
[1]