저는 Alamofire을 처음 사용합니다. 그러나이 작업은 정말 간단해야하며 왜 문제가 발생하는지 잘 모르겠습니다. .Alamofire 4.0.1 SSL 요청 실패 (서버에 대한 보안 연결을 만들 수 없음)
나는 XCode8, Swift3 및 Alamofire 4.0.1를 사용하여 건물 에 대한 iOS9하고 있습니다.
내가 액세스하는 URL은 GoDaddy에서 구입 한 새로운 인증서로 보호됩니다. Chrome과 Safari 모두 내 MacBookPo에 보안 사이트를로드 할 수 있으며 모든 것이 잘 어울립니다.
그러나 다음 코드를 다음과 같은 오류에
Alamofire.request(buildRequestString().addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)!).validate().responseJSON { response in
switch response.result {
case .success(let data):
print(JSON(data))
case .failure(let error):
print(error)
}
}
결과 : (I 보안상의 이유로 내 주소/도메인을 교체하지)
[] nw_coretls_read_one_record tls_handshake_process: [-9801]
[] nw_endpoint_flow_protocol_error [1.1 12.345.67.890:443 in_progress socket-flow (satisfied)] TLS protocol sent error: [-9801]
[] nw_endpoint_flow_protocol_disconnected [1.1 12.345.67.890:443 in_progress socket-flow (satisfied)] Output protocol disconnected
[] nw_endpoint_resolver_receive_report [1 sub.domain.ext:443 in_progress resolver (satisfied)] received child report:[1.1 12.345.67.890:443 failed socket-flow (satisfied)]
[] nw_connection_endpoint_report [1.1 12.345.67.890:443 failed socket-flow (satisfied)] reported event flow:failed_connect, error Error Domain=kNWErrorDomainTLS Code=-9801 "Security Error: -9801" UserInfo={NSDescription=Security Error: -9801}
[] nw_connection_endpoint_report [1 sub.domain.ext:443 failed resolver (satisfied)] reported event flow:failed_connect
[] __tcp_connection_start_block_invoke 1 sending event TCP_CONNECTION_EVENT_DISCONNECTED in response to state failed and error Error Domain=kNWErrorDomainTLS Code=-9801 "Security Error: -9801" UserInfo={NSDescription=Security Error: -9801}
[] tcp_connection_event_notify 1 event: TCP_CONNECTION_EVENT_DISCONNECTED, reason: nw_connection event, should deliver: true
[] tcp_connection_cancel 1
[] nw_endpoint_handler_cancel [1 sub.domain.ext:443 failed resolver (satisfied)]
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)
[] nw_endpoint_handler_cancel [1.1 12.345.67.890:443 failed socket-flow (satisfied)]
[] nw_resolver_cancel_on_queue 0x600000101b00
[] -[NWConcrete_tcp_connection dealloc] 1
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9801, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x608000046e70 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9801, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9801}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://sub.domain.ext/api/v1/Assignment?query=%22%22&device=%22%22, NSErrorFailingURLStringKey=https://sub.domain.ext/api/v1/Assignment?query=%22%22&device=%22%22, _kCFStreamErrorDomainKey=3}
누구도 날에 관한 몇 가지 통찰력을 줄 수 왜이 오류가 발생하고 있습니까? 유효한 인증서가 있지만 사이트가 신뢰되지 않는 것처럼 보입니다. 이 연결을 허용하도록 조정해야하는 XCode 내에 다른 설정이 있습니까? Alamofire 문서는 위 코드가 모두 필요한 것임을 나타 냈습니다.
https://www.ssllabs.com/ssltest/index.html을 사용하여 사이트를 확인하십시오. TLS, 전달 비밀 키를 지원하는지 확인하고 중간 인증서를 보냅니다. –
좋아요. 그래서 그 사이트에서 'F'점수를 받았습니다. TLS 1.2를 지원하지 않는이 새로운 인증서 (어제 받았어)처럼 보입니까?!?!? 감사합니다 GoDaddy ... 그래서 내 옵션은 무엇입니까? – Xorcist
TLS1.2 지원은 인증서 자체와 관련이 없습니다. 그보다는 웹 서버를 어떻게 구성 했느냐에 달려 있습니다. 사이트에 인증서를 배포하고 SSL을 활성화 했습니까? 아니면 GoDaddy에서 수행 했습니까? 웹 서버에 따라 TLS 지원을 활성화하고 Apple의 ATS 표준을 준수하는 것이 매우 쉽습니다. –