SSL Certificate Problem: Unable to get Local Issuer Certificate

Better Stack Team
Updated on May 4, 2022

Problem

Received SSL certificate problem: unable to get local issuer certificate error when executing curl request to a secure HTTPS destination.

Cause of the problem

If you get SSL certificate problem: unable to get local issuer certificate error, it's an indication that your root and intermediate certificates on the system are not working correctly or not set up correctly.

Solution

  1. Download the latest cacert.pem from https://curl.haxx.se/ca/cacert.pem 
  2. Add the --cacert /path/to/cacert.pem flag to the curl command to tell curl where the local Certificate Authority file is.

If you are using PHP:

Add the following line to the php.ini file or users.ini if you are on the shared hosting:

 
curl.cainfo="/path/to/downloaded/cacert.pem"

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github