Application stop suddenly and getting NSURLErrorDomain error - ios

I am using IOS 13.3 and my application stop suddenly after 6 month.
I have checked my certificate and found no issue in certificate.
i am getting the following error.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
2020-04-17 01:38:14.778140+0530 Example[38000:704335] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> HTTP load failed (error code: -1200 [3:-9816])
2020-04-17 01:38:14.779009+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> finished with error - code: -1200
2020-04-17 01:38:14.782985+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://api.example.com:1410/v1.1/users/signin, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, kCFStreamErrorDomainKey=3, NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.example.com:1410/v1.1/users/signin, NSUnderlyingError=0x600002db3d50 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFNetworkCFStreamSSLErrorOriginalValue=-9816, kCFStreamErrorDomainKey=3, kCFStreamErrorCodeKey=-9816}}, kCFStreamErrorCodeKey=-9816} [-1200]
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
Here is the screenshot
I'm not sure how to solve it. Any ideas?

You probably need to reconfigure your SSL certificates. I know for TCP/TLS at least, with iOS 13 they imposed more restrictions on the certificates. I created a package to handle sockets on iOS - I also included a lot of good info about making certificates how you need to now.
https://github.com/eamonwhiter73/IOSObjCWebSockets/tree/master

Related

After successfully installing a cert on iPhone simulator, I still get an SSL error when hitting my web service

I am developing a web service and iOS app that hits the web service on my local machine. At first, I disabled the cleartext errors for interacting with the service, but now I would like to use https so that my development, test, and prod environments are as similar as possible.
I installed my self-signed cert locally, so going to the site directly is using https just fine:
I have followed the instructions to install a cert in the iPhone simulator:
However, when I hit the web service on my local machine that uses this cert, I still get these error in the console:
2020-10-17 09:59:10.891496-0500 cttios[45481:2146304] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
2020-10-17 09:59:10.899475-0500 cttios[45481:2146304] ATS failed system trust
2020-10-17 09:59:10.899583-0500 cttios[45481:2146304] Connection 1: system TLS Trust evaluation failed(-9802)
2020-10-17 09:59:10.899744-0500 cttios[45481:2146304] Connection 1: TLS Trust encountered error 3:-9802
2020-10-17 09:59:10.900077-0500 cttios[45481:2146304] Connection 1: encountered error(3:-9802)
2020-10-17 09:59:10.901405-0500 cttios[45481:2146304] Task <BE791070-705B-4C7D-A1DB-F57BCF1DFBCE>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802])
2020-10-17 09:59:10.904343-0500 cttios[45481:2146304] Task <BE791070-705B-4C7D-A1DB-F57BCF1DFBCE>.<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
"<cert(0x7ff4ce854600) s: cttweb.test i: Homestead homestead Root CA>"
), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://cttweb.test/api/v1/login, NSErrorFailingURLStringKey=https://cttweb.test/api/v1/login, NSUnderlyingError=0x600001123ab0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x600002d55cb0>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, kCFStreamPropertySSLPeerCertificates=(
"<cert(0x7ff4ce854600) s: cttweb.test i: Homestead homestead Root CA>"
)}}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <BE791070-705B-4C7D-A1DB-F57BCF1DFBCE>.<1>"
), _kCFStreamErrorCodeKey=-9802, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <BE791070-705B-4C7D-A1DB-F57BCF1DFBCE>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x600002d55cb0>, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.}
Login api error: An SSL error has occurred and a secure connection to the server cannot be made.
Optional(["task": ["Login api error: An SSL error has occurred and a secure connection to the server cannot be made."]])
I have tried restarting the simulator after installing the cert, same result. What am I doing wrong?
It looks like I may not be trusting the cert even after installing it, but I can't find a way to trust it.
The problem is that I had the website cert installed, but not the CA cert generated for my local web server installed. That was as easy as dragging the CA root cert into Safari on the simulator.

iOS - AVPlayer can't stream video url from https localhost server

I'm trying to create a streaming app on iOS. So at first I tried with an http url and it didn't work because of security reasons they say so I created an https server on Android using NanoHTTPD and I'm able to access the new https server with Android and Windows devices connected on the same network albeit with warnings. Now I added this on my Info.plist file
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
But it still remains the same and then I ran the app on the simulator and the logs gave me this
2019-09-21 15:40:07.540419+0800 SampleAVPlayerStream[8746:47938] 80: Failed to set processVolumeScalar on device. Error: 560947818
2019-09-21 15:40:07.859455+0800 SampleAVPlayerStream[8746:47938] TIC SSL Trust Error [1:0x6000017fb480]: 3:0
2019-09-21 15:40:07.877511+0800 SampleAVPlayerStream[8746:47938] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2019-09-21 15:40:07.881312+0800 SampleAVPlayerStream[8746:47938] Task <8F036D25-D6CC-433E-A61E-CD5A844CFAF5>.<1> HTTP load failed (error code: -1202 [3:-9813])
2019-09-21 15:40:07.886919+0800 SampleAVPlayerStream[8746:47938] Task <8F036D25-D6CC-433E-A61E-CD5A844CFAF5>.<1> finished with error - code: -1202
2019-09-21 15:40:07.900192+0800 SampleAVPlayerStream[8746:48024] Task <8F036D25-D6CC-433E-A61E-CD5A844CFAF5>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.0.27” which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
"<cert(0x7fc32a084600) s: Gus Fakelastname i: Gus Fakelastname>"
), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://192.168.0.27:8080/Videos/heyheyhey.mp4, NSErrorFailingURLStringKey=https://192.168.0.27:8080/Videos/heyheyhey.mp4, NSUnderlyingError=0x600002c9c4b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x6000010e8750>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9813, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9813, kCFStreamPropertySSLPeerCertificates=(
"<cert(0x7fc32a084600) s: Gus Fakelastname i: Gus Fakelastname>"
)}}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <8F036D25-D6CC-433E-A61E-CD5A844CFAF5>.<1>"
), _kCFStreamErrorCodeKey=-9813, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <8F036D25-D6CC-433E-A61E-CD5A844CFAF5>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x6000010e8750>, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.0.27” which could put your confidential information at risk.} [-1202]
Update: This is the logs if I revert the server back to http
2019-09-21 19:12:37.829817+0800 SampleAVPlayerStream[4270:23381] Task <D17E6DB2-73F5-4C8D-92B7-A10B0EECD8BD>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=http://192.168.0.27:8080/Videos/heyheyhey.mp4, NSErrorFailingURLKey=http://192.168.0.27:8080/Videos/heyheyhey.mp4, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <D17E6DB2-73F5-4C8D-92B7-A10B0EECD8BD>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <D17E6DB2-73F5-4C8D-92B7-A10B0EECD8BD>.<1>, NSLocalizedDescription=cancelled} [-999]
2019-09-21 19:12:37.826346+0800 SampleAVPlayerStream[4270:23254] Task <D17E6DB2-73F5-4C8D-92B7-A10B0EECD8BD>.<1> finished with error - code: -999
Here is the Swift code.
if let urlVal = NSURL(string: "https://192.168.0.27:8080/Videos/heyheyhey.mp4") {
let player = AVPlayer(url: urlVal as URL);
let vc = AVPlayerViewController();
vc.player = player;
present(vc, animated: true) {
vc.player?.play();
}
}

Xcode Firebase Authentication not working

My Firebase authentication is not working. Here is the log from the console:
2017-06-02 08:12:18.928 Study M8[67744] <Warning> [Firebase/Analytics][I-ACS003016] Firebase Analytics App Delegate Proxy is disabled. To log deep link campaigns manually, call the methods in FIRAnalytics+AppDelegate.h.
2017-06-02 08:12:19.544 Study M8[67744:2637901] Simulator user has requested new graphics quality: 10
2017-06-02 08:12:19.576 Study M8[67744] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at https://firebase.google.com/support/guides/analytics-adsupport
2017-06-02 08:12:19.619 Study M8[67744] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4000000 started
2017-06-02 08:12:19.621 Study M8[67744] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
2017-06-02 08:12:19.748 Study M8[67744] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
2017-06-02 08:12:19.755 Study M8[67744] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled
2017-06-02 08:12:20.454 Study M8[67744:2638259] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2017-06-02 08:12:20.456 Study M8[67744:2638259] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2017-06-02 08:12:20.573 Study M8[67744:2637901] <Firebase/Network/ERROR> Encounter network error. Code, error: -1200, Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60800004e610 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=3}
2017-06-02 08:12:20.576 Study M8[67744] <Error> [Firebase/Core][I-NET901017] <Firebase/Network/ERROR> Encounter network error. Code, error: -1200, Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60800004e610 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=3}
2017-06-02 08:12:20.577 Study M8[67744] <Error> [Firebase/Analytics][I-ACS901017] Encounter network error. Code, error: -1200, Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x600000052720 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://app-measurement.com/config/app/1:1030084793656:ios:2caba89d2a97a5b1?platform=ios&app_instance_id=7B84A3F451A04EBEAB26BE84DE23D1D4&gmp_version=4000, NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:1030084793656:ios:2caba89d2a97a5b1?platform=ios&app_instance_id=7B84A3F451A04EBEAB26BE84DE23D1D4&gmp_version=4000, _kCFStreamErrorDomainKey=3}
2017-06-02 08:12:20.580 Study M8[67744] <Error> [Firebase/Core][I-COR000020] Error posting to Clearcut: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60800004e610 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, _kCFStreamErrorDomainKey=3}, with Status Code: 0
2017-06-02 08:12:28.627210+1000 Study M8[67744:2637901] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/jack.staples/Library/Developer/CoreSimulator/Devices/A86AAB47-B72B-41D0-9FE3-6BAA9F7097ED/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-06-02 08:12:28.634587+1000 Study M8[67744:2637901] [MC] Reading from private effective user settings.
2017-06-02 08:12:37.313 Study M8[67744:2638259] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2017-06-02 08:12:37.317 Study M8[67744] <Error> [Firebase/Analytics][I-ACS901017] Encounter network error. Code, error: -1200, Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9806, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x60800024dc20 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://app-measurement.com/config/app/1:1030084793656:ios:2caba89d2a97a5b1?platform=ios&app_instance_id=7B84A3F451A04EBEAB26BE84DE23D1D4&gmp_version=4000, NSErrorFailingURLStringKey=https://app-measurement.com/config/app/1:1030084793656:ios:2caba89d2a97a5b1?platform=ios&app_instance_id=7B84A3F451A04EBEAB26BE84DE23D1D4&gmp_version=4000, _kCFStreamErrorDomainKey=3}
2017-06-02 08:12:37.324 Study M8[67744:2638259] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
If anyone has any idea whats going on the help is really appreciated.
Add this lines to your plist file:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Unable to get a secure connection to AWS DynamoDB

I keep getting the following errors trying to write to a table in my ios objective-c app:
The request failed. Error: [Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9824, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSUnderlyingError=0x12764c8f0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9824, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9824}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.
What is wrong above?

nscurl --ats-diagnostics doesn't work with my nodejs server

I have setup nodejs for SSL with certificates from ssls.com. When I run tests from the browser my certificates are found and things seem okay (excepting a couple of vulnerabilities are shown). I'm using sites like:
https://www.sslshopper.com/ssl-checker.html
https://www.ssllabs.com/ssltest/analyze.html
Notwithstanding I'm having trouble getting my IOS app to connect using a websockets library.
When I run this new diagnostic command:
nscurl --ats-diagnostics https://<mydomain.com> I get
nscurl[4714:325661] CFNetwork SSLHandshake failed (-9806)
nscurl[4714:325661] NSURLSession/NSURLConnection HTTP load failed
(kCFStreamErrorDomainSSL, -9806)
The more detailed log file doesn't seem to give much more info:
Error: Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)"
UserInfo={_kCFStreamPropertySSLClientCertificateState=0,
_kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806}
Any ideas?

Resources