小编alf*_*red的帖子

使用自签名证书在iOS 9中发出HTTPS请求

我想使用自签名证书向自定义服务器发出HTTPS请求.我正在使用NSURLConnection类并处理身份验证问题,但始终在控制台中收到错误消息:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
Run Code Online (Sandbox Code Playgroud)

然后使用以下错误调用方法"connection:didFailWithError:":

Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x150094100>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey=<CFArray 0x1500ddd90 [0x19f6dab68]>{type = immutable, count = 1, values = (
    0 : <cert(0x14e6fb370) s: (server certificate name) i: (custom CA name)>
)}, NSUnderlyingError=0x1504ae170 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be …
Run Code Online (Sandbox Code Playgroud)

ssl https objective-c self-signed ios

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

https ×1

ios ×1

objective-c ×1

self-signed ×1

ssl ×1