UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUI development against webapi on local machine causing Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid"

Forums > SwiftUI

I am trying to develop apis on my local machine which are consumed by my SwiftUI application. I followed your https://www.youtube.com/watch?v=MBCX1atOvdA video on calling an API, but when I try to call the one on my own machine I get an 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 “localhost” which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway

My webapi works, as I can run it and see results in the browser using local host (I have also tried w/IP as well and it works).

I have followed a number of instructions to try and ensure my simulator can connect to the API including:

  • Exporting certificate from Keychain and dragging it into the simulator
  • Adding a variety of settings to Info.plist under NSAppTransportSecurity (NSAllowArbitraryLoads, NSAllowsLocalNetworking, NSAllowsArbitraryLoads, NSExceptionDomains)

Is there any chance you could do a video on this? I have seen a lot of posts and a lot of confusion.

2      

I could use some help with this too, actually I am not even looking for a good productive solution but just for a development solution.

I found a great API of Philips Hue and love to use this to see if I can create an app which uses this API data to control my lights. I just want to get more knowledge on implementing SwiftUI and don't want to dive into SSL Certificate issues right now. The Hue developer guide explains how you can start with PostMan by temporary disabling ssl through the property "disable ‘SSL certificate verification".

I understand that I should provide a real fix when I want to ship the app but for now I just want to play with the API so if anyone knows if there is an way to ignore the SSL errors then I would be really happy :P

1      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.