Posts Tagged ‘letsencrypt’

[Techy] Getting cURL to work with Let’s Encrypt: unable to get local issuer certificate error

May 4th, 2016

On my test Debian jessie 8.2 and a staging server Ubuntu trusty 14.04, I had problems being able to use cURL to fetch data from a remote HTTPs site which was secured using a free Let’s Encrypt certificate (this problem manifested itself via both PHP 7 cURL functions and curl directly).

An example of the error is:

curl --verbose
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here:

To fix this, I found the following steps worked:
sudo apt-get install --reinstall ca-certificates
to ensure you have the latest certificates by your distribution – this might help you, but it didn’t assist me 🙁

So I downloaded the Let’s Encrypt root certificates and forced a rebuild of the certificate store:

sudo curl -o /usr/local/share/ca-certificates/isrgrootx1.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptauthorityx1.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptauthorityx2.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptx1.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptx2.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptx3.crt
sudo curl -o /usr/local/share/ca-certificates/letsencryptx4.crt
sudo dpkg-reconfigure ca-certificates

and everything worked!

If you are running Java, you may need to also add the certificates to the Java Keytool:
keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -file /usr/local/share/ca-certificates/isrgrootx1.crt
keytool -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -importcert -file /usr/local/share/ca-certificates/letsencryptauthorityx1.crt

(change the storepass password [default of “changeme”] to whatever is relevant to you)

%d bloggers like this: