我正在尝试通过Alamofire使用自签名证书。
let trustPolicy = ServerTrustPolicy.pinCertificates(证书: [证书],validateCertificateChain:true,validateHost:true)
let serverTrustPolicies: [String: ServerTrustPolicy] = [ "https:-domain-name": trustPolicy,"domain-name" : .disableEvaluation] let policyManager = ServerTrustPolicyManager(policies: serverTrustPolicies)
但是我遇到以下错误。
CredStore-copyIdentPrefs-复制身份凭据时出错。 错误= -25300,查询= { class = idnt; labl =“ https://domain-name:443/”; “ r_Ref” = 1; }
和
[BoringSSL] boringssl_context_alert_callback_handler(3724) [C1.1:2] [0x139d1bd20]警报级别:致命,描述:握手 失败2019-01-22 15:34:23.448605 + 0530 DB [1276:264543] [BoringSSL] boringssl_session_errorlog(224)[C1.1:2] [0x139d1bd20] [boringssl_session_handshake_incomplete] SSL_ERROR_SSL(1):操作 库内失败
2019-01-22 15:34:23.448796 + 0530
DB [1276:264543] [BoringSSL] boringssl_session_handshake_error_print(205)[C1.1:2] [0x139d1bd20] 5266093016:错误:10000410:SSL 例程:OPENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl/boringssl-109.230.1/ssl/tls_record.cc:586:SSL 警报编号40
2019-01-22 15:34:23.448986 + 0530 DB [1276:264543]
[BoringSSL] boringssl_context_get_error_code(3545) [C1.1:2] [0x139d1bd20] SSL_AD_HANDSHAKE_FAILURE
2019-01-22
15:34:23.464957 + 0530 DB [1276:264543] TIC读取状态 [1:0x281599800]:1:-9824
2019-01-22 15:34:23.467598 + 0530
DB [1276:264543]任务<43E199F9-B030-4BFD-B9E0-8C9F59B43E72>。<1> HTTP加载失败(错误代码:-9824 [1:-9824])
2019-01-22
15:34:23.468019 + 0530 DB [1276:264574]任务 <43E199F9-B030-4BFD-B9E0-8C9F59B43E72>。<1>已完成,但发生错误-代码: -9824 2019-01-22 15:34:23.470149 + 0530 DB [1276:264574]任务<43E199F9-B030-4BFD-B9E0-8C9F59B43E72>。<1>加载失败并出现错误 错误域= NSPOSIXErrorDomain代码= -9824“未知错误:-9824” UserInfo = {_ NSURLErrorFailingURLSessionTaskErrorKey = LocalDataTask <43E199F9-B030-4BFD-B9E0-8C9F59B43E72>。<1>, _kCFStreamErrorDomainKey = 1,NSErrorPeerAddressKey = {长度= 16,容量= 16,字节= 0x100201bb03106e120000000000000000},_ kCFStreamErrorCodeKey = -9824, _NSURLErrorRelatedURLSessionTaskErrorKey =( “ LocalDataTask <43E199F9-B030-4BFD-B9E0-8C9F59B43E72>。<1>”)} [-9824]
过去1周以来一直在尝试此操作。任何帮助将不胜感激。
答案 0 :(得分:0)
在Alamofire中禁用评估不会禁用证书的系统基本验证,该验证默认情况下会阻止自签名证书。我建议您阅读Apple's ATS documentation,但我想您的域和其他设置需要结合NSExceptionAllowsInsecureHTTPLoads
才能使用。如果可以的话,还应该确保不要发布这些设置。