SSL Certificates HOWTO
SSL Certificates HOWTO
Franck Martin
Revision History
Revision v0.1 2001−11−18 Revised by: fm
A first hand approach on how to manage a certificate authority (CA), and issue or sign certificates to be used
for secure web, secure e−mail, or signing code and other usages.
SSL Certificates HOWTO
Table of Contents
Chapter 1. Generalities .....................................................................................................................................1
1.1. History..............................................................................................................................................1
1.2. Introduction.......................................................................................................................................1
1.2.1. Disclaimer and Licence....................................................................................................1
1.2.2. Prior knowledge................................................................................................................2
1.3. What is SSL and what are Certificates?............................................................................................2
1.3.1. Private Key/Public Key:...................................................................................................2
1.3.2. The Certificate:.................................................................................................................2
1.3.3. The Symmetric key:..........................................................................................................3
1.3.4. Encryption algorithm:.......................................................................................................3
1.3.5. The Hash:..........................................................................................................................3
1.3.6. Signing:.............................................................................................................................4
1.3.7. PassPhrase:........................................................................................................................4
1.4. What about S/Mime or other protocols?...........................................................................................4
i
Chapter 1. Generalities
1.1. History
V0.1 − Franck Martin <franck@[Link]>
1.2. Introduction
Dear reader, like myself you have read intensively the man pages of the applications of the OpenSSL project,
and like myself, you couldn't figure out where to start, and how to work securely with certificates. Here is the
answer to most of your questions.
This HOWTO will also deal with non−linux applications, as there is no use to issue certificates if you can't
use them... May be all applications won't be listed here, but please send me additional paragraphs and
corrections. I can be reached at the following address:franck@[Link].
In short, if the advises given here break the security of your e−commerce application, then tough luck− it's
never our fault. Sorry.
Copyright (c) 2001 by Franck Martin and others from the openssl−users mailing list under GFDL (the
GNUFree Documentation License).
Please freely copy and distribute (sell or give away) this document in any format. It's requested that
corrections and/or comments be forwarded to the document maintainer. You may create a derivative work
and distribute it provided that you:
1. Send your derivative work (in the most suitable format such as sgml) to the LDP (Linux
Documentation Project) or the like for posting on the Internet. If not the LDP, then let the LDP know
where it is available.
2. License the derivative work with this same license or use GPL. Include a copyright notice and at least
a pointer to the license used.
3. Give due credit to previous authors and major contributors. If you're considering making a derived
work other than a translation, it's requested that you discuss your plans with the current maintainer.
It is also requested that if you publish this HOWTO in hardcopy that you send the authors some samples for
'review purposes' :−). You may also want to send something to cook my noodles ;−)
Chapter 1. Generalities 1
SSL Certificates HOWTO
someone, you have to implicitly trust, you have his/her certificate loaded in your browser. A certificate,
contains information about the owner of the certificate, like e−mail address, owner's name, certificate usage,
duration of validity, and resource location or Distinguished Name (DN) which includes the Common Name
(CN) (web site address or e−mail address depending of the usage) and the certificate ID of the person who
certify (sign) this information. It contains also the public key and finally a hash to ensure that the certificate
has not been tampered with. As you made the choice to trust the person who sign this certificate, therefore
you also trust this certificate. This is what is called a certificate trust tree. Usually your browser or application
has already loaded the root Certificate of well known Certification Authorities (CA) or root CA Certificate.
The CA maintains a list of all signed certificates as well as a list of revoked certificates. A certificate is
insecure until it is signed, as only a signed certificate cannot be modified. You can sign certificate using
itself, it is called a self signed certificate. All root CA certificates are self signed.
1.3.6. Signing:
Signing a message, means authentifying that you have yourself assured the authenticity of the message. The
message can be a text message, or someone else certificate. To sign a message, you create its hash, and then
encrypt the hash with your private key, you then add the encrypted hash and your signed certificate with the
message. The recipient will recreate the message hash, decrypts the encrypted hash using your well known
public key stored in your signed certificate, check that both hash are equals and finally that it trusts the
certificate.
1.3.7. PassPhrase:
A passprase is like a password except it is longer. In the early days passwords on Unix system were limited to
8 characters, so the term passphrase for longer passwords. Longer is the password more difficult it is to guess
it. Nowadays Unix systems use MD5 hashes which have no limitation in length of the password.
In a reverse order, the browser can send its own signed certificate to the web server, as a mean of
authentication. But everybody can get the browser certificate on the CA web site. Yes, but the signed
certificate has been sent encrypted with the private key, that only the public key can decrypt.
1.3.6. Signing: 4
Chapter 2. Certificate Management
2.1. Installation
Nowadays, you do not have to worry too much about installing OpenSSL, as most distributions use package
management applications. Refer to your distribution documentation, or read the README and INSTALL file
inside the OpenSSL tarball.
I describe here some standard installation options which are necessary to know in case your installation
differ.
The directory for all OpenSSL certificates is /var/ssl/. All commands and paths in this document are issued
from this directory, it is not obligatory but it will help the examples.
OpenSSL by default look for a configuration file in /usr/lib/ssl/[Link] so always add −config
/etc/[Link] to the commands openssl ca or openssl req for instance if the configuration file is located
elsewhere. I use /etc/[Link] so my configuration files are all in /etc.
Ensure that the utility [Link] is in an accessible directory such as /usr/sbin. [Link] can be found inside
/usr/lib/ssl directories. [Link] is a utility that hides the complexity of the openssl command.
#$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"}
$SSLEAY_CONFIG="−config /etc/[Link]";
/etc/[Link] example
[Link] −newca
creates a self signed certificate (for Certificate Authority). The resulting file goes into [Link]. For the
common Name (CN) use something like ACME root Certificate. This file needs to be split into 2 files
[Link] and private/[Link]. The part −PRIVATE KEY− goes into private/[Link] while the part
−CERTIFICATE− goes into [Link]. Delete [Link] when finished.
Now ensure that the file [Link] is empty and that the file serial contains 1.
You may want to increase the number of days so that your root certificate and all the certificates signed by
this root does not have to be changed when the root certificate expires. I think professional companies work
over 5 years for their root certificates.
openssl req −config /etc/[Link]−new −x509 −keyout [Link] −out [Link] −days 1825
Now ensure that this self signed root certificate is used only to sign other certificates. The private key is
highly sensible, never compromise it, by removing the passphrase that protects it.
Now you have a root Certification Authority. Other people need to trust your self−signed root CA Certificate,
and therefore download it and register it on their browser.
You will have to type the passphrase each time you want to sign another certificate with it.
It is possible to use any signed certificate to sign any other certificate, provide that the certificate is valid and
has been issued with the signing capability. So you can create a certificate request and a private key, make the
certificate been signed by a third party and install the signed certificate and private key. The part −PRIVATE
KEY− goes into private/[Link] while the part −CERTIFICATE− goes into [Link].
Place this file on your web site as [Link] Your web server has a mime entry for .crt
files. Your certificate is ready to be downloaded by browser and saved on to their hard drive.
2.4.1. In Netscape
FIXME
2.4.2. In Galeon
FIXME
creates a new private key and a certificate request and place it as [Link].
[Link] −sign
(openssl ca −config /etc/[Link] −policy policy_anything −out [Link] −infiles [Link]
will sign the request using the [Link] and commit the certificate as [Link]. You will need to enter
the passphrase of the [Link] (your CA Certificate). The file newcerts/[Link] will be created and
[Link] and serial will be updated.
You private key is in [Link] −PRIVATE KEY− and your certificate is in [Link]
−CERTIFICATE−
A copy of [Link] is placed in newcerts/ with an adequate entry in [Link] so that a client can request
this information via a web server to ensure the authenticity of the certificate.
Beware of your [Link] file, because it contains a certificate request, but also your private key. The
−PRIVATE KEY− section is not required when you sign it. So if you request someone else to sign your
certificate request, ensure that you have removed the −PRIVATE KEY− section from the file. If you sign
someone else certificate request, request from this person its −CERTIFICATE REQUEST− section not its
private key.
The database is updated and the certificate is marked as revoked. You need now to general the new revoked
list of certificates:
First you have to revoke the previous certificate and sign again the certificate request.
To find the old certificate, look in the [Link] file for the Distinguished Name (DN) corresponding to the
request. Get the serial Number <xx>, and use the file cert/<xx>.pem as certificate for the revocation
procedure.
You may want to sign the request manually because you have to ensure that the start date and end date of
validity of the new certificate are correct.
1. You must publish your root CA Certificate, so that it can be installed in applications.
2. You must publish the revocation list.
3. You must display a certificate detail, provided its serial number
4. You must provide a form for users to submit certificate requests.
All these requirements can be done using a web server and some scripting.
First generate and sign a certificate request with the Common Name (CN) as [Link].
The key needs to be made insecure, so no password is required when reading the private key. Take the
[Link] files that contains your private key and remove the passphrase from it.
Because the key (PRIVATE Key) is insecure, you must know what you are doing: check file permissions,
etc... If someone gets its hand on it, your site is compromised (you have been warned) Now you can use the
newcert and [Link] for apache.
Edit /etc/httpd/conf/ssl/[Link]−[Link].
−−−−
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill −HUP will prompt again. A test
# certificate can be generated with `make certificate' under
# built time.
#SSLCertificateFile conf/ssl/[Link]
SSLCertificateFile [Link]
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file.
#SSLCertificateKeyFile conf/ssl/[Link] SSLCertificateKeyFile [Link]
−−−−
Stop and start httpd (/etc/rc.d/init.d/httpd stop) ensure that all processes are dead (killall httpd) and start httpd
(/etc/rc.d/init.d/httpd start)
Import this file in the OpenSSL /var/ssl directory rename it to [Link] and sign the request as usual.
[Link] −sign
The file [Link] is not yet suitable for key manager as it contains some text and the −CERTIFICATE−
section. We have to remove the text, the easy way is to do:
Using a text editor is also suitable to delete everything outside the −CERTIFICATE− section.
Export the file [Link] to the Computer running key Manager and while selecting the key, right
click and click on Install the Key Certificate, select this file, enter the passphrase. The key is now fully
functional.
Now sign your message [Link] (output [Link]) using your certificate [Link] and your key
[Link]:
openssl smime −sign −in [Link] −text −out [Link] −signer [Link] −inkey [Link]
Beware this certificate contains your public and private key and is only secured by the passphrase. This is a
file not to let into everybody's hand.
In MS Outlook go to Tools, Options and Security, Click on the import/export button select to import the
newcert.p12 file, enter the export password and the Digital ID "Franck Martin" (That's my name so use your
name in the above examples). And Click on Ok.
Now click on the Settings button, MS Outlook should have selected the default setting so just click on New.
And finally click on Ok, except if you want to change the default settings. You are ready to send signed
e−mails. When you send a signed e−mail the user at the other end will receive your public key, and will
therefore be able to send you encrypted e−mails.
As you have issued this certificate from a self−signed certificate (root CA Certificate), the trust path won't be
valid because the application does not know the root CA Certificate. The root CA certificate has to be
downloaded and installed. Refer to the chapter "Install the CA root certificate as a Trusted Root Certificate in
Internet Explorer"