Root CA certificates need to be added to your local trust list when working with PKI. We will examine how to add root CA certificate and optionally some intermediate certificates to the trust store.

Quick solution

First step of importing root certificate in Ubuntu is to make sure it is PEM format, ends with .crt and copying to /usr/local/share/ca-certificates.
Second step is running update-ca-certificates command
See more detailed info below

Signature and certificate debugging

Openssl is very handy tool for everything related to PKI, Digital Signatures and Certificates.

$ openssl verify 38112086027.cer 
C = EE, O = ESTEID, OU = digital signature, CN = "PALA,MARGUS,38112086027", SN = PALA, GN = MARGUS, serialNumber = 38112086027
error 20 at 0 depth lookup: unable to get local issuer certificate
error 38112086027.cer: verification failed

Certificate was not verified and to make it trusted we need to import issuer CA and add it to local trust store. To resolve this issue then lets first examine signer certificate and find the Issuer CA certificate. For this I exported the certificate from my ID card and examined it with openssl.

$ openssl x509 -in 38112086027.cer -text -noout
        Version: 3 (0x2)
        Serial Number:
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = EE, O = AS Sertifitseerimiskeskus, organizationIdentifier = NTREE-10747013, CN = ESTEID-SK 2015
            Not Before: Nov  8 07:49:24 2017 GMT
            Not After : Oct 12 20:59:59 2022 GMT
        Subject: C = EE, O = ESTEID, OU = digital signature, CN = "PALA,MARGUS,38112086027", SN = PALA, GN = MARGUS, serialNumber = 38112086027
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (384 bit)
                ASN1 OID: secp384r1
                NIST CURVE: P-384
        X509v3 extensions:
            X509v3 Basic Constraints: 
            X509v3 Key Usage: critical
                Non Repudiation
            X509v3 Certificate Policies: 

            X509v3 Subject Key Identifier: 
            X509v3 Authority Key Identifier: 

            Authority Information Access: 
                OCSP - URI:
                CA Issuers - URI:

            X509v3 CRL Distribution Points: 

                Full Name:

    Signature Algorithm: sha256WithRSAEncryption

Missing bit here is CA Issuers – URI:

Similarly the ESTEID-SK_2015.der.crt is intermediate signing certificate and its root is EE_Certification_Centre_Root_CA.pem from Estonia which is usually installed to Ubuntu already contrary to many other countries Root CA-s

Adding certificate to trusted list

I downloaded this certificate, verified that it is the correct, converted to better supported PEM format and verified that this is indeed to correct certificate.

 $ openssl x509 -in ESTEID-SK_2015.der.crt -inform der -out ESTEID-SK_2015.pem.crt
$ openssl verify -CAfile ESTEID-SK_2015.pem.crt 38112086027.cer 
38112086027.cer: OK

First step of importing root certificate in Ubuntu is to make sure it is PEM and ends with .crt and copying to /usr/local/share/ca-certificates.
Second step is update-ca-certificates

$ sudo cp ESTEID-SK_2015.pem.crt /usr/local/share/ca-certificates
$ sudo update-ca-certificates
Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

Now you will see the certificate properly configured in /etc/ssl/certs, signing certificate trusted and also signature trusted.

$ openssl verify 38112086027.cer 
38112086027.cer: OK

Possible problems

Openssl issues in version 1.1.1f

If you do same thing in Ubuntu 18.04 and Ubuntu 20.04 then you might see differences.

Ubuntu 18.04 current openssl version is

$ openssl version
OpenSSL 1.1.1  11 Sep 2018

In Ubuntu 20.04 the openssl version is newer. In fact preinstalled 1.1.1f is broken so in my machine I built newer version 1.1.1g from source and it is still not 100% good even though other issues there are better. Issue is upgrading from 1.1.1.e and 1.1.1.f causes openvpn connections using ssl to fail. #11456

Certificate permissions issue

It can happen that newly added certificate does not have read permissions for all users

139650177364416:error:0200100D:system library:fopen:Permission denied:../crypto/bio/bss_file.c:290:fopen('/usr/lib/ssl/certs/cceef5f6.0','r')
139650177364416:error:20074002:BIO routines:file_ctrl:system lib:../crypto/bio/bss_file.c:292:
139650177364416:error:0B06F002:x509 certificate routines:X509_load_cert_file:system lib:../crypto/x509/by_file.c:84:

In this case helps to add read permission to this certificate

$ sudo chmod +r /usr/local/share/ca-certificates/ESTEID-SK_2015.pem.crt

Categories: e-ID


Leave a Reply