Accueil VPSie

Retour à la base de connaissances

Introduction à OpenSSL

OpenSSL est un ensemble de bibliothèques et d'utilitaires C pour les systèmes d'exploitation Linux, *BSD, Solaris, AIX, Windows (et autres) qui implémente les protocoles SSL et TLS, et fournit des fonctions et utilitaires cryptographiques pour l'administration PKI. Le travail quotidien d'un administrateur de VPS Linux implique l'utilisation d'OpenSSL pour générer des certificats, les vérifier et dépanner les problèmes SSL/TLS et les sites web HTTPS.

Certificats SSL – le concept

As the name suggests, Openssl certificates are digital certificates that allow two parties, usually an HTTPS webserver and client (browser) or two IPSEC endpoints, to authenticate to each other and encrypt and sign data that they exchange. HTTPS is the mechanism of encrypting clear text HTTP protocol using SSL or TLS, it is secure (in theory), hence the S. HTTPS is intended to be secure because it uses a pair of private and public key each encoded in separate certificates: Private certificate (usually referred to as the key) and public certificate (usually referred to as the CRT or PEM certificate). PEM is actually an encoding mechanism of SSL certificates. SSL public certificates can be self signed (they are their own issuer) or they can be signed by a recognized Certificate Authority (CA) – free or commercially. In the case of the vast majority of HTTPS website, they obtain the public / private key pair (an SSL private certificate/key actually holds a public public [modulus] key and a private [exponent] key) via internally generated mechanisms such as Openssl or via 3rd party security devices. From the private part, OpenSSL will extract the public key (modulus) and create a Certificate Signing Request (CSR). The CSR is sent to a public or private Certificate Authority to sign the CSR that results in a public certificate. The public certificate Subject and Issure sections, after it has been signed, will look like:

    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Class 1 Primary Intermediate Server CA
        Validity
            Not Before: Feb  5 02:45:55 2015 GMT
            Not After : Feb  5 15:43:21 2016 GMT
        Subject: C=NL, CN=www.domain.com/[email protected]
This tells the browser that the certificate it receives from the HTTPS website is valid for www.domain.com, it is valid between Feb 5 2015 and Feb 5 2016 and that it is signed by Issuer which the browser already trusts. Thus, the browser will not display a warning when it accesses the website at https://www.domain.com in the time interval when the certificate is valid. The security of HTTPS websites is founded on the basic principle (and more complex SSL handshake) that the public certificate provided by an HTTPS server to its clients is signed by a 3rd party – the Certificate Authority – that is trusted by these clients, as in the example above.

Utilisation d'Openssl pour générer des certificats pour votre serveur web HTTPS sur un VPS Linux

En tant que client VPSie, lorsqu'un serveur VPS Linux est déployé, une fois le VPS personnalisé et sécurisé selon vos exigences, il est temps de déployer les paquets Linux qui permettront de transformer votre serveur VPS en serveur de services. Si le périmètre du VPS est de devenir un site HTTPS, vous aurez besoin de la paire de clés privée/publique (clé privée) et d'une CSR.

Génération de certificats SSL OpenSSL

Tous nos paquets VPS Linux sont livrés avec OpenSSL par défaut, il n'y a donc aucun prérequis direct pour générer la clé privée SSL et la demande de signature de certificat (CSR). À propos de Openssl genrsa Vous pouvez utiliser le dossier /etc/ssl/ pour stocker vos certificats. Le module openssl responsable de la génération de la clé privée RSA est genrsa. Une clé privée peut être chiffrée à l'aide des algorithmes DES/3DES/AES/Camelia ou non. Si vous choisissez de la chiffrer, une phrase de passe sera requise.
root@vpsie:~# cd /etc/ssl/private/
root@vpsie:/etc/ssl/private# openssl genrsa -h
usage: genrsa [args] [numbits]
 -des            encrypt the generated key with DES in cbc mode
 -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)
 -seed
                 encrypt PEM output with cbc seed
 -aes128, -aes192, -aes256
                 encrypt PEM output with cbc aes
 -camellia128, -camellia192, -camellia256
                 encrypt PEM output with cbc camellia
 -out file       output the key to 'file
 -passout arg    output file pass phrase source
 -f4             use F4 (0x10001) for the E value
 -3              use 3 for the E value
 -engine e       use engine e, possibly a hardware device.
 -rand file:file:...
                 load the file (or the files in the directory) into
                 the random number generator
Générer une clé privée chiffrée / un certificat
root@vpsie:/etc/ssl/private# openssl genrsa -aes128 -out private.key 2048
Generating RSA private key, 2048 bit long modulus
..................................................+++
...................................................+++
e is 65537 (0x10001)
Enter pass phrase for private.key:
Verifying - Enter pass phrase for private.key:
Maintenant que nous avons la clé privée, l'étape suivante consiste à générer une demande de signature de certificat qui devra être envoyée à une Autorité de Certification pour signature :

root@vpsie:/etc/ssl/private# openssl req -new -key private.key -out certificate.csr
Enter pass phrase for private.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York
Organization Name (eg, company) [Internet Widgits Pty Ltd]My Linux VPS
Organizational Unit Name (eg, section) []:VPS
Common Name (e.g. server FQDN or YOUR name) []:www.mydomain.com
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
root@vpsie:/etc/ssl/private# cat certificate.csr
-----BEGIN CERTIFICATE REQUEST-----
MIIC3jCCAcYCAQAwgZgxCzAJBgNVBAYTAlVTMREwDwYDVQQIDAhOZXcgWW9yazER
MA8GA1UEBwwITmV3IFlvcmsxFjAUBgNVBAoMDVZNeSBMaW51eCBWUFMxDDAKBgNV
BAsMA1ZQUzEZMBcGA1UEAwwQd3d3Lm15ZG9tYWluLmNvbTEiMCAGCSqGSIb3DQEJ
ARYTYW5kcmVpQG15ZG9tYWluLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBALOjKtbuRemm88No93EfoGeVZU+7IGr6AIaqX0esKDxq5Vtlm+71gc2z
msRL6G7xJU4DvbBdOKBkSKaSdEhPt4uCtgHJpNSA1ez0s2FFXASbN3LPR9oxmyxl
W8oCmAkZNP9B+H0i9kpRs3FtVQzb3fWVMw9slB7bh2p1ZZg/PJm7fE2uAg7vcMAg
9FL+MNKKq7WDSafGqvCV+kVYmguAmgGbsfq2wB0X6I9v0i7sx0Fxmc+B8ZwDj1us
heq5Lt9kF4c63DEjfGhIG8wT8aCIgir7PdCHttppfJz4uXK092EI37ImwDl2lKsX
+Rg2ojqhXzKbxtX4mZoZS0dUlOhladcCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IB
AQA/zOGxiGx8JW4SCnY99bsaiA4zr/a0g33A7E/tSx4gNP9C5CKUk3TUNrZL0h4h
dEwr5yNcp90UWo0zZ6TXid+XaaAcGaF63uX+GrE5lIBSmCX3BohHAaKlYIZG9Pr/
I0pSMfqU6dQQy4CbMiFy0hrBBgcdQIs1xeFVHtU8uG1nFAAsHM+7kaGIjD8yYiOo
4Hf+bEzN+PUEmOwRNsxs4tT4MpeR1U7BBRevtzh3sZ3pRNlJ2lPX/z2+P3rQUARc
9Fq92ORt5TrJHUnTO4tsYxBf8W5P9qckXbmMM9jkMfIDx5RQ0QaTxyaI1uO70Srg
gMZSPb8FRdqtgc1Xha/FIAhK
-----END CERTIFICATE REQUEST-----
Dans un prochain article, nous aborderons comment obtenir un certificat SSL gratuit auprès d'une Autorité de Certification de confiance.

Vous pouvez en effet tester ces configurations SSL sur notre plateforme en quelques minutes en utilisant notre PCS (Private Cloud Solution), qui vous permet de disposer de VPSie(s) sur un réseau privé – NAT – redirection de ports – contrôle du trafic entrant et sortant – plusieurs adresses IP de passerelle que vous pouvez utiliser pour l'équilibrage de charge et la bascule.

                    Try us free for one full month today! 

Retour à la base de connaissances