Flutter SSL error with Laravel Herd

Flutter SSL error on API call to Laravel API on Herd

Patrick Riemer

When you develop a mobile application in Flutter or iOS and connect to your local API in Laravel using Herd, you most likely will get an error similar to the following:

                    
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: application verification failure(handshake.cc:393))
                    
                

The reason is that iOS does not trust the Herd issued root certificate which is used to sign your local site’s SSL certificates.

The easiest solution is to add the root certificate to the trust store of your iOS simulator. On your iOS simulator, open the Settings and browse to:

                    Settings > General > About > Certificate Trust Settings
                

Trust store before importing root certificate

Now locate the certificate file of Herd’s Valet:

                    ~/Library/Application Support/Herd/config/valet/CA
                

Now drag and drop the file “LaravelValetCASelfSigned.pem” into your iOS simulator. The result should look like follows:

Trust store after import of root certificate

Calls to your local API should work fine now.