Skip to content

Instantly share code, notes, and snippets.

@koraykupe
Forked from abdumu/howTo.txt
Last active April 4, 2023 00:38
Show Gist options
  • Save koraykupe/d24d4554c4768238ab0dd9f9979b1e2e to your computer and use it in GitHub Desktop.
Save koraykupe/d24d4554c4768238ab0dd9f9979b1e2e to your computer and use it in GitHub Desktop.
How to fix SSL certificate errors on NativeScript iOS & Laravel Valet setup?

If you have an API and run it on Laravel Valet, you may get errors about SSL ceritifate when you do a call to the API.

An example error you may see:

  • Network request failed: The certificate for this server is invalid. You might be connecting to a server that is pretending to be [your local domain] which could put your confidental information at risk.

How to Fix

-1- edit ~/.composer/vendor/laravel/valet/cli/stubs/openssl.conf Change: basicConstraints = CA:FALSE

To: basicConstraints = CA:TRUE,pathlen:0

save file.

-2- go to your website folder, run: valet secure

-3- drag ~/.valet/Certificates/[website.domain].crt to iOS simulator to add it there.

-4- From iOS simulator, - go to Settings->about->Certificates Trust Settings

-5- drag ~/.valet/CA/LaravelValetCASelfSigned.pem to iOS simulator to add it there.

-6- From iOS simulator, - go to Settings->about->Certificates Trust Settings - Enable Full Trust for your website cert.

-7- add the snippet below /app/App_Resources/iOS/Info.plist file in your NativeScript project:

'NSAppTransportSecurity NSAllowsArbitraryLoads '

Use it just for local development. App Store guideline doesn't allow to publish an app with this setting.

-8- run 'tns platform clean ios', close simulator and re-build / run it.

Enjoy

@serdarcevher
Copy link

Please note that this might still give you headaches because of the issue mentioned here: laravel/valet#1103

Laravel Valet's root certificate (LaravelValetCASelfSigned) is only valid for 2 years after the initial creation. I'm just trying to renew it without completely purging the Valet installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment