I have an app that is used by different companies. The user first needs to log in throughout a webservice with always the same base-url. When he is logged in successfully I get a base-url (with htttps) back from the webservice. But this base-url is different for each company.
Now when I start my app in IOS9 and I log in and try to call the webservices with the different base-url, I get this error:
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorCodeKey=-9847, NSErrorFailingURLStringKey=https://81.82.219.213:8080/TechAppService/TechAppService.svc//authuser?login=***&password=***
I know that I need to set up the NSAppTransportSecurity dictionary in the info.plist. The problem now is that I don't know how I can set this in code.
Step-1
select info.plist and click Right --> go to Source Code
Step-2
the source code open as Key Format , on that key add the following keys in last
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
you can see like sample output
Step - 3
it automatically added in your plist just like follows
Its because there are few changes in iOS 9 SDK to use network in apps. you need to add following key in info.plist file.
Step 1: Open info.plist file in your project.
Step 2: Add App Transport Security Settings key.
Stpe 3: Add child key Allow Arbitrary Loads and set value to YES.
Thats all for more details read apple documentation.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Paste this into the end of your Info.plist This will allow all connections
Please set it in Info.plist. For more info see in the given image
Related
i am trying to send remote notification using one signal and i made all certificates right when i run application and check one signal i got this "We haven't detected any subscribed users yet for this platform" and i found this in my log in xcode "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={_kCFStreamErrorCodeKey=-9816, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?" and i have been searching online all the day and i tried every solution i found and it did not work i also done this in info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Try using a different network.
it seems that the problem is one signal does not open in my country , thanks
WKWebView doesn't load http requests, only https is working. My Url's strings are fetched from an API, so the url's links could be http and https. I did read about security, however the only thing I found was to add the following lines to the Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key> NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
However, in the .plist these keys don't exist. Is there any way to make WKWebView load http web content, and would the app be approved by the App Store?
I'm using Xcode 9.
1: Open your info.plist file from the project
2: add App Transport Security Settings in Information Property List
3: add Allow Arbitrary Loads in App Transport Security Settings
See the attached images
You can ignore all transport security restrictions with the key your provided using the following:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
I assume your example is not working due the space in the key:
<key> NSAllowsArbitraryLoadsInWebContent</key>
Try to use the same value as you did but without the space.
I created sample app using SAP Cloud platform, it also generated Proxy classes with backend url "http://staging.*****.com/OData/sapiOS.svc/". When I running the app it didn't display the details and shows an error:
" JsonError: Expected token start character, found '<'." JsonError.
You can ignore all app transport security restrictions with a single key add these to the Info.plist open as Source Code:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
I check my server with :
nscurl --verbose --ats-diagnostics https://xxx
It shows my server only supports TLSV1.0, but my API works fine and I can get my JSON data with it .
When I get my image URL with JSON data to load my image by SDWebImage,it shows
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)
So, I'm confused,
If my server doesn't support the minimum TLS version, why does my API work?
Otherwise, if my server is ok, why does XCode show that kCFStreamErrorDomainSSL wrong?
My image URL is also similar:
https://xxx.xxxxx.xxx/xxx.jpg
In the info.plist of your project, you need to add a key "Add Transport Security Settings" which is a dictionary and contains a variable "Allow Arbitrary Loads" which is boolean and is set to true.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run my app on iOS 9 device,
got error logged:
App Transport Security has blocked a cleartext HTTP (http://) resource
load since it is insecure. Temporary exceptions can be configured via
your app's Info.plist file.
I surely did add NSAllowsArbitraryLoads to info.plist:
It still loaded nothing from the web...
What did I miss?
Do I have to allow the certain domain for my web service ?
I have found how to fix this query.
Ref->How do I load an HTTP URL with App Transport Security enabled in iOS 9?
-> Open Plist File of your project.
-> Then add NSAppTransportSecurity as a Dictionary.
-> Then add NSAllowsArbitraryLoads as Boolean and set its value to YES.
Now, Clean your project and run your project.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
please add these line in your plist 1- go to plist 2- right click and go to open as -> source code 3- paste these line in source code