Search code examples
iosswiftalamofire

connect with Windows SSL server through iOS app using alamofire


In my server i have implemented SSL certificate and connected through my android app using retrofit just by passing URL and parameter. now i am developing iOS version of the app using Alamofire to connect with same API but getting SSL error.

[BoringSSL] Function boringssl_session_errorlog: line 2866 [boringssl_session_handshake_continue] SSL_ERROR_SSL(1): operation failed within the library [BoringSSL] Function boringssl_session_handshake_error_print: line 2805 boringssl ctx 0x7fcff052b0d0: 140531107629232:error:100000f0:SSL routines:OPENSSL_internal:UNSUPPORTED_PROTOCOL:/BuildRoot/Library/Caches/com.apple.xbs/Sources/boringssl_Sim/boringssl-109.50.14/ssl/handshake_client.c:970: [BoringSSL] Function boringssl_context_get_os_status: line 4304 SSL_AD_PROTOCOL_VERSION

TIC TCP Conn Failed [1:0x6000001708c0]: 3:-9802 Err(-9802) NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) Task <76674C26-EED0-41DE-BB94-A0FF9F8F22A0>.<1> HTTP load failed (error code: -1200 [3:-9802])

My code in swift 4 to connect with server

Alamofire.request("https://url/token", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: [:]).responseJSON { response in if response.result.isSuccess{ print(“success”) } else { print ("Error (String(describing: response.result.error))") }

is there anything additional need to be done to connect iOS with network. I have gone through various questions already posted by various users but nothing worked for me.


Solution

  • iOS 9.0 or later have built in support for ATS which is enabled by default. Alamofire works with https// but for that NSAllowsArbitraryLoads need to be defined in info.plist by adding NSAllowsArbitraryLoads=YES

    However disabling ATS is not recommended.