When you use different self hosted services, such as your own Gitlab instance for example, you probably use self signed certificates for securing the connection. Self-signed certificates have the disadvantage that Browsers and other applications do not trust them and therefore either display error messages or refuse to connect at all. The IDEA IntelliJ IDE for instance does not clone from repositories which are protected by self signed certificates. Instead of disabling the SSL certificate verification completely, it is recommended to add your self signed certificate to the local certificate store.
Ubuntu and other Linux distributions store certification authorities in the file
/etc/ssl/certs/ca-certificates.crt. This file is a list of trusted public keys, which is compiled by appending all certificates with the file ending .crt
in the directory <span class="lang:default decode:true crayon-inline ">/etc/ssl/certs . Once a CA is in this list, the operating system trusts all certificates which have been signed by this CA. You could simply add the public part of the server certificate to this file, but it might get overwritten once the root CAs are updated. Therefore it is the better practice to simply store your self signed certificate in the mentioned directory and trigger the creation of the
ca-certificates.crt file manually.
Fetch the Certificate from your Server
First, retrieve the certificate from your server. The command below trims away the information that is not needed and writes the certificate public key into a new file within the certificate directory. Run this command as root.
echo | openssl s_client -connect $SERVERADDRESS:443 2>/dev/null | openssl x509 > /usr/local/share/ca-certificates/$SERVERADDRESS.crt
Update the Certificate Authority File
Then, by simply running the command sudo update-ca-certificates
, the certificate will be added and trusted, as a link is created within the directory /etc/ssl/certs
. The output of the command should mention that one certificate was added. Note that the command creates a new symbolic link from the file $SERVERADDRESS.crt
to$SERVERADDRESS.pem`. This certificate will then be accepted by all applications, which utilise the ca-certificates file.