私はAlamofireを初めて利用しましたが、これは本当にシンプルにする必要があります。 。Alamofire 4.0.1 SSLリクエストが失敗しました(サーバとの接続は安全にできません)
私はSwift3XCode8、を使用して、そして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)
}
}
結果:(私はセキュリティ上の理由のために私のアドレス/ドメインを交換する必要はありませ)
[] 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のサポートは証明書自体に関連していません。むしろ、あなたのWebサーバーをどのように設定したかによって異なります。あなたのサイトに証明書を展開してSSLを有効にしたのですか、それともGoDaddyで完了しましたか? Webサーバーによっては、TLSサポートを有効にして、サイトをAppleのATS標準にするのはかなり簡単です。 –