I am trying to implement a system where a client can download application packages from a server to install/update them on the client. I suppose that the client is something like a platform on an embedded system. For integrity of the application packages, I am considering using a digital signature.

I did some research and found that the client would have to have a CA certificate and the server would have to have a server certificate signed by a CA and a private key. I know that the server certificate could be issued by a CA if I asked. Then, the server would store it somewhere and send it with application packages and signatures of them so that the client can verify them using a CA certificate.

My questions is what the client is supposed to do to install/update a CA certificate. When we used other type of client such as web browsers and mail applications, we would not recognize what those applications are doing for installing/updating a CA certificate. But I would need to implement it on the client.

My questions are

  1. Is the client supposed to download a CA (root) certificate from a web site of the CA before it is used?
  2. Or does a CA (root) certificate has to be pre-installed on the client?
  3. Or is the server supposed to keep a CA certificate and tell the client where to download the CA certificate?
  4. What is the client supposed to do to update a CA certificate for some reason?

I would appreciate it if someone could reply to me.


I'll answer the questions in order:

  1. No because a download may not convey trust. You could have a download over SSL, but you would rely on the pre-existing trust structure used for SSL. Furthermore you will need to explain to a user what they would have to do to establish trust and configure the application.

  2. Usually root certificates are distributed with the application, yes. Needless to say that the download needs to be trustworthy. If the application install cannot be trusted then all trust is out of the window anyway.

  3. The chain of certificates (up to the root certificate) is often kept with the private key yes. In the end the client needs to build a chain of trust up to a certificate it trusts. This may be a root certificate, but it may also be a CA certificate. Usually it is a root certificate because:

    1. the root certificate has a much longer - or indefinite - validity period;

    2. the root key is only used to create CA certificates and is therefore much safer (it's often kept off-line).

    With most protocols both the CA certificate and the leaf certificate are included with the signature. In that case the client only needs to know & trust the root certificate to validate a signature.

  4. It should either use a CRL or OCSP to lookup the status of the certificates. If you trust a root certificate then you may just sign with a new key/certificate signed with the root key. Of course if you loose confidentiality of all trusted certificates (i.e. the root certificate/key) then you need to completely reestablish trust somehow.

All of the above in total is called PKI, you may want to read into it, especially with regards to key management.

  • Thank you for the reply. What I understand from your answer is i) it would be enough for a client to have a root certificate to validate a signature, ii) the root certificate can be pre-installed on a client or distributed with application packages from the server, iii) a client would need to build a chain of trust, iv) a client would need to use CRL or OCSP, but the server would just sign with a new key. Honestly, I do not quite understand iii) and iv) yet. I wonder if there is any explanation about those at an implementation level. – mille-printemps Dec 29 '14 at 16:07

The Official Way

The certificate is a valid legal identification for a person/company/agency. As with any formal document you have to obtain it from an official Certificate Authority. There are many. As a developer you have to get from them at least 2 certificates: one for your server, and one for you as a client. To get them you have to do a requisition. When you do this you'll be granted your certificate and your private key file for every certificate.

After this legal process you can install it on your apache server like this:

  • First you install the certificate chain in the server. These are some certificates, publicly available from the CA (certificate authority).
  • This chain, can be only one root certificate or many.
  • If there are many you put them all in a file together. There are other ways but I found this one to be better.

Then you add this lines to you apache configuration:

SSLEngine on
SSLOptions +StdEnvVars +ExportCertData
SSLCertificateFile      /home/<youruser>/<yourCertFolder>/server.crt #server file
SSLCertificateKeyFile   /home/<youruser>/<yourCertFolder>/server.key #server private key
SSLCertificateChainFile /home/<youruser>/<yourCertFolder>/rootCA.crt #server certificate  chain
SSLCACertificateFile    /home/<youruser>/<yourCertFolder>/rootCA.crt #server CA certicate file (if you're in the test process below, should be the same file above)
SSLVerifyClient require
SSLVerifyDepth  10
  • Go to your browser and import the certificate chain of the CA that issued the certificates.
  • Import your personal certificate to it. There are some certificate types. If you bought A1 (files) certificates you just import it to the browser. If you bought an A3 token (like an USB flashdrive but for certificates) you have to first load the driver to the browser and then it will import it automatically when you enter a SSL enabled site.
  • The certificate you're using in the browser has to have the exact same certificate chain than the server is using or the server won't be able to validate it.
  • After this you should see a window asking you to select you cerficate when entering the site.

Lot of stuff huh ? believe me, learning this was an harsh process.

The Test Way

But there is something you can use as a test process. You can create you own CA and emmit your own certificates locally in your server and development machine. Here's how you do it:

First install openssl in your machine if it's not already installed. Then use these scripts:

Create CA and server certificate:

echo "Create CA private key"
openssl genrsa -des3 -passout pass:123 -out  ./rootCA.key 2048
echo "Remove passphrase"
openssl rsa -passin pass:123 -in ./rootCA.key -out ./rootCA.key
echo "Create CA self-signed certificate"
openssl req -config openssl.cnf -new -x509 -subj '/C=US/L=Dev/O=COMPANY/CN=CA' -days 99999 -key ./rootCA.key -out ./rootCA.crt
echo "Create private key for the server"
openssl genrsa -des3 -passout pass:123 -out ./server.key 2048
echo "Remove passphrase"
openssl rsa -passin pass:123 -in ./server.key -out ./server.key
echo "Create CSR for the server"
openssl req -config ./openssl.cnf -new -subj '/C=US/L=Dev/O=COMPANY/CN=server' -key  ./server.key -out ./server.csr
echo "Create certificate for the server"
openssl ca -batch -config ./openssl.cnf -days 999 -in ./server.csr -out ./server.crt -keyfile ./rootCA.key -cert ./rootCA.crt -policy policy_anything

issuing certificates:

if [[ -z "$1" || -z "$2" ]]; then
    echo "Use: issueCertificate <NAME>"
echo -e "\nCreating folder... " 
mkdir $ARQ
echo "done."
echo -e "\nCreating private key... "
openssl genrsa -des3 -passout pass:123 -out ./$ARQ/$ARQ.key 2048
echo "done."
echo -e "\nRemoving password..."
openssl rsa -passin pass:123 -in ./$ARQ/$ARQ.key -out ./$ARQ/$ARQ.key
echo "done."
echo -e "\nCreating CSR... "
openssl req -config ./openssl.cnf -new -subj "$DN" -key ./$ARQ/$ARQ.key -out ./$ARQ/$ARQ.csr
echo "done."
echo -e "\nCreating client certificate"
openssl ca -batch -config ./openssl.cnf -days 999 -in ./$ARQ/$ARQ.csr -out ./$ARQ/$ARQ.crt -keyfile ./rootCA.key -cert ./rootCA.crt -policy policy_anything
echo "done."
echo -e "\nExport client to pkcs12 and import in browser"
openssl pkcs12 -export -passout pass:123 -in ./$ARQ/$ARQ.crt -inkey ./$ARQ/$ARQ.key -    certfile ./rootCA.crt -out ./$ARQ/$ARQ.p12
echo "done."

So I guess that's all. I've has to translate some things and change some var names and constants in order to remove my company's name and this whole process is rather complex. So I appologize if I forgot something or something doesn't work. Please inform and I'll correct promptly.

Good luck. :)

  • Thank you for the detail information. I guess that this is about configuring a server for SSL communication, which is a little bit different case from mine. But I think that this is also useful to test my case, which is about a digital signature. – mille-printemps Dec 29 '14 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy