Swift - The certificate for this server is invalid - ios

How can I fix this on iOS using Swift? When I'm making a server request I get the following error:
The certificate for this server is invalid. You might be connecting to a server that is pretending to be “...” which could put your confidential information at risk.

You just need to install the certificates on the iOS simulators
From Charles Documentation:
Quit your iOS Simulator. Launch Charles and go to the Help menu.
Choose the "SSL Proxying > Install Charles Root Certificate in iOS
Simulators" item. This will install your Charles Root Certificate into
all of your iOS Simulators. Now when you start the iOS Simulator, you
should be able to access SSL websites with Charles using SSL Proxyin

You are most probably trying to connect to server with self-signed ssl certificate. iOS does not like it.
Take a look at this post as an example: Swift SSL error with self signed certificate.
Other possible issue is a proxy configuration with something like Charles behind it.
More details will maybe help to identify the root of the issue...

Related

Charles proxy doesn't work on my IOS device

Here's what I did so far:
Install Charles on my mac
Connect mac and iPhone to same WiFi network
Charles->Proxy->SSL Proxy Settings. Enable for *
General->About->Certificate Trust Settings and enable full trust for the Charles Proxy certificate.
Charles->Help->Install Charles Root Certificate on a Mobile Device
Configure iPhone to proxy to IP provided in step 3.
And then when I try to go to safari on my Iphone I get a "connection lost" error and It's impossible to browse.
Any solutions ?
I'm on IOS 11.4
I used to have the same problem when SSL Proxying on iOS device then I changed to the following steps and it works:
Install Root Certificate on my mac
Configure Wifi Proxy on iOS device to Charles:
Server: 172.16.1.191
Port: 8888
Open Safari on iOS device:
Browse to chls.pro/ssl to download and install the certificate
Install Charles CA Certificate on your device:
iOS ≥ 10.3: Setting app > General > Profiles > Select Charles CA > Install
iOS ≥ 12.2: Setting app > Profiles Downloaded > Select Charles CA > Install
Trust Charles CA Certificate on your device:
Setting app > General > About > Certificate Trust Settings > Switch ON on Charles CA
Honestly, this is based on the iOS Setup Guide of an app named Proxyman. They have similar features like Charles but the UX is better I suppose. Anw, hope it helps :)
I had the same issue yesterday and spent a lot of time trying all possible solutions. But, what worked for me was restarting my router and do all these steps again.
Note: In case you are not able to download the certificate on your iOS device by going to Safari browser (chls.pro/ssl), you can download the certificate from the Charles app on your mac, save in local, then send it to your iOS device and install from there.
Path for the same in Charles app is - Help -> SSL Proxying -> Save Charles Root Certificate
Go to the Wifi setting, Configure Proxy under HTTP PROXY to Manual.
Provide the Server IP from Charles and Port to 8888.
Browse to chls.pro/ssl to download and install the certificate in your phone.
Refer to the answer here: Cannot see iOS simulator traffic with charles proxy
Ensure that ATS is present for debug builds.

Charles proxy doesn't work even after installing the root certificate on iphone device

Here's what I did so far:
1. Install Charles on my mac
2. Connect mac and iPhone to same WiFi network
3. Charles->Proxy->SSL Proxy Settings. Enable for *
4. Charles->Help->Install Charles Root Certificate on a Mobile Device
5. Configure iPhone to proxy to IP provided in step 3.
6. on iPhone, went to chls.pro/ssl and installed root certificate.
The iPhone web traffic shows in Charles, but is still ssl encrypted. What am I missing?
Go to General->About->Certificate Trust Settings and enable full trust for the Charles Proxy certificate.

OTA deploy with certificate error for iOS8

I have a certificate problem when install app with OTA deployment site in intranet.
The OTA site is not SSL, it works fine with iOS 6.x, but it just failed to install in iOS 8 with certificate problem.
We don't use MDM for deployment and I have tried to use self-signed certificate to build a SSL OTA site, but it still failed.
I want to ask if there is any advise to fix this problem?
Thank you very much!
You have to use a real SSL certificate with new iOS versions. Using self-made certificate might work if you install it on the devices, but I haven't tried this.
Note that the actual ipa doesn't have to be on a SSL secured site, only the plist file. And you could use 3rd party file storing services to host that file and have the ipa on another server.

Continuous Integration with iOS 7.1 - can't install the product linked on the server

We've been running CI with Xcode 5.0 for some time with no issue. Now iOS 7.1 has been released it seems to install the products that the CI produces you need to be on https but it seems that self signed certs are ok.
I have switched to https (self-signed) which loads the bot page fine, but when you go to install the product from the link it says cannot connect to server
Trying to install it on http causes the error Cannot install applications because the certificate for 'server' is not valid..
Do I have to get a proper certificate or am I doing something wrong with the self signed cert?
It seems it's the same problem although it needs to be signed with your own CA authority rather than just a self signed certificate.
For instructions on how to do this follow the instructions here.

Debug BlackBerry App SSL Certificate Problems

We are testing a BlackBerry app that accesses a secure RESTful service.
One of our customers is getting an "Access Denied: Insecure SSL Request" error when trying to access our web service. The customer device is running OS6. We have not been able to reproduce this with an OS6 simulator. The cert is installed on the simulator that matches his device.
We have seen similar cert problems with OS5 devices and simulators. We are using a Root Level Certificate (Thawte Primary CA) that is not installed on BlackBerry OS5. We have been able to solve similar problems on the OS5 devices by manually installing the certificate.
The manual cert install fix works for accessing the service from the OS6 devices' browser, but we get a "Access Denied: Insecure SSL Request" error when trying a https operation from our app. We are not able to reproduce this on any of our devices.
Questions:
Does the "Access Denied: Insecure SSL Request" error indicate the customer's device isusing the BlackBerry Enterprise Server? All google results for this error indicate the BES.
This cert has a wildcard that points to our many sub-domains. Could switching to a cert that explicitly points to the problem domain solve this? We recently changed our certs, but they work fine on iOS, Android, IE, FireFox & Chrome.
Any there any code changes we can make to fix this? We are creating the connection using the HttpsConnection. We are developing using the Java 5.0 libaray.
What other steps would you recommend for trying to track down this problem?

Resources