Https

De Mi caja de notas

Cette page a démarré sur iwc:https et migrera après traduction sur iwc:https-fr

HTTPS est l'abréviation de Hypertext Transfer Protocol Secure, littéralement « protocole de transfert hypertexte sécurisé », supporté par les serveurs web (comme Apache & nginx) et les navigateurs. HTTPS est la combinaison du Protocole de Transfert Hypertexte (HTTP) avec une couche de chiffrement comme les protocoles SSL/TLS.

Pourquoi

Pourquoi ?

  • Confidentialité par défaut. Tim Bray a posté sur le fait de servir son site via https (https://www.tbray.org/ongoing/When/201x/2012/12/02/HTTPS)
    • "Ce blog n'est pas très controversé, mais si les choses "controversées" sont privées, alors la vie privée est elle-même suspecte.
    • "Parce que je peux, c'est la seule petite partie de l'Internet où j'ai le contrôle complet." (https://willnorris.com/2012/12/all-https-all-the-time)
  • Réduire la persécution politique/religieuse/sociale. Si l'employeur d'un lecteur, une école/université, une communauté religieuse ou la famille suivent l'usage du net, activer le HTTPS/SSL veut dire qu'ils ne peuvent pas voir quelles sont les pages spécifiques qui ont été vues sur ce site. C'est un bon outil (loin d'être parfait) pour se protéger contre les "petits adversaires" —persécuteurs politiques, des membres de la famille homophobes, des communautés religieuses intolérantes à la critique ou à la libre pensée— de voir quelles sont les pages d'un site Web particulier que quelqu'un est en train de regarder.
    • tommorris : Si je me trompe de cybersécurité, certains de mes amis pourraient ne pas avoir de maisons.
  • Gains de performance à utiliser HTTP/2 (https://www.httpvshttps.com). La plupart des vendeurs de navigateurs ont décidé de n'implémenter que HTTP/2 au lieu de TLS, i.e. https://. [1]
  • Rang de recherche. Google classe désormais les sites https plus haut que les sites non-https (http://googleonlinesecurity.blogspot.co.uk/2014/08/https-as-ranking-signal_6.html)
  • Intégrité de pubication. Si vos pages sont distribuées via https, les ISP's, ou quiconque au milieu, ne peuvent pas injecter de contenu et des headers dans votre site - c'est à dire :
  • Réduire le traçage niveau opérateur

Comment faire

Obtenir un certificat

Acheter ou obtenir des certificats SSL gratuits aujourd'hui

  • Let's Encrypt est une autorité ouverte de certificat, gratuite, automatisée, qui existe pour le bénéfice public. Sponsorisée par Mozilla et l'Electronic Frontier Foundation, parmi d'autres, Let’s Encrypt automatise et vous évite les maux de crâne, et permet aux opérateurs de site d'activer et de gérer HTTPS avec de simples commandes.
  • StartSSL offre des certificats SSL gratuits pour les domaines uniques. Si vous vérifiez votre identité, ils vous permettent aussi d'enregistrer des certs gratuits wildcard. Néanmoins, en 2016 il a été retiré du certificat racine de Mozilla et d'Apple. cf iwc:StartSSL#Criticism
  • namecheap.com offre des certificats SSL domaine-unique pour $7.95/year et des certificats wildcard pour $85/year
  • GlobalSign offre des certificats wildcard gratuits (!) pour les projets open source.
  • ssls.com a des certificats SSL bon marché provenant de plusieurs fournisseurs. En date du 2014/03/08, un certificat PositiveSSL valait $4.99/an pour un engagement sur 5 ans. Ils fournissent aussi des certificats SSL *gratuits* SSL pour des périodes de 90 jours.
  • CAcert est une organisation à but non lucratif qui fournit des certificats wildcard gratuits. Malheureusement le certificat racine n'est pas inclus par défaut dans la majorité des systèmes d'exploitation et navigateurs. Ces certs sont généralement utilisés dans la communauté GNU.
  • Amazon Web Services fournit des certificats SSL gratuits qui peuvent être utilisés avec d'autres services Amazon. Il n'y a pas d'installation requise autre que de cliquer dans l'interface web.
  • WoSign est une autorité de certification qui offre des certificats validés pour les domaines. Néanmoins, en 2016 elle a été retirée du certificat racine de Mozilla et Apple. Voir iwc:StartSSL#Criticism

Valider votre Achat

Les fournisseurs de certificats SSL exigent quelque forme de validation de vous, votre domaine, et votre propriété du domaine.

Génération CSR — Une "Certificate Signing Request" doit être générée pour votre site. Par exemple, sur un fournisseur d'hébergement qui utilise Cpanel, le "Manager SSL/TLS" a une section "Certificate Signing Requests".

Approuver Email — ssls.com asks for an "Approver Email" from a list of administration email addresses and Domain Registration email addresses. Choose one that you use, and receive the Domain Control Validation email, which contains a link and a "validation code". Click the link and enter the code to verify that you own the domain.

Certificate Email — ssls.com send the certificate to the "Administrator Email" that you specified during the purchase process. This certificate is used in the process below.

Gérer

When you're done with your purchase, you'll have one or more files for each certificate:

  • The certificate itself, e.g. snarfed.org.ssl.crt.
  • The private key you used to generate the certificate, e.g. id_rsa-2048.
  • Optional: Your CA's intermediate cert, e.g. sub.class1.server.ca.pem.
  • Optional: Your CA's root, e.g. ca.pem. Hopefully you picked a CA whose root cert is distributed with most OSes/browsers; if so, you can ignore this. (If you didn't, you should reconsider!)

All of these files are usually X.509 format except the private key, which is RSA or other private key format.

Command line openssl is your friend for inspecting and editing certificates. For example, to dump info about a cert:

openssl x509 -text -in snarfed.org.ssl.crt

If your CA provided an intermediate cert, you'll need to provide it to your web server along with your own cert. For servers that only accept a single file, you'll need to concatenate the certs, e.g.:

cat snarfed.org.ssl.crt sub.class1.server.ca.pem > snarfed.org.unified.ssl.crt

As another example, it seems like this command line should verify that a cert is valid:

openssl verify -verbose -CAfile ca.pem snarfed.org.unified.ssl.crt

...but User:snarfed.org gets this error:

error 20 at 0 depth lookup:unable to get local issuer certificate

You will get the "error 20" error above when openssl is unable to locate the root or intermediate certificates in your chain - if you are on Linux, or know where your OS stores the certificate list, you can run:

openssl verify -verbose -CApath /etc/ssl/certs snarfed.org.unified.ssl.crt

If you have gnutls command line tools installed, you can verify self-signed certs:

certtool -e --infile snarfed.org.unified.ssl.crt


Réglages

The IETF has a document with recommendations for Secure Use of TLS and DTLS.

Mozilla has a great tool to build the SSL Configuration for various tools: Mozilla SSL Configuration Generator.

https://cipherli.st is a quick cheatsheet for Apache, nginx and Lighttpd TLS configuration.

testssl.sh is a command line tool for viewing your TLS configurations.

Apache

Apache is pretty easy. Here's a good how-to post. TL;DR: Put the certificate files somewhere your Apache user can read, then set the SSLCertificate* config directives, e.g.:

SSLCertificateKeyFile /home/ryan/.ssh/id_rsa-2048
SSLCertificateFile /home/ryan/www/snarfed.org.ssl.crt
SSLCACertificateFile /home/ryan/www/sub.class1.server.ca.pem

User:ShaneHudson.net - As well as the certificates and keys, it is also useful to have forward secrecy and HSTS. I used the following lines in httpd.conf, the articles I found them in are in the FAQs further below. This went from C to A+ on the SSL test.

SSLProtocol all -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
    Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"

App Engine

If you're serving on Google AppEngine's built-in appspot.com domain, you're already done! Just add secure: always (or optional) to the handler(s) in your app.yaml or other app config file, and you'll be able to access your app over https. Details here.

If you're using the Java runtime on App Engine, add this stanza to your web.xml file.

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 
   ...> 

  <security-constraint>
    <web-resource-collection>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>

You may additionally want to send a HSTS header to further improve security. In java, the easiest way from a servlet running on AppEngine is to add this header to all responses when running on the production server.

import com.google.appengine.api.utils.SystemProperty;

...

      if (SystemProperty.environment.value() ==
          SystemProperty.Environment.Value.Production) {
          // force ssl for six months.
          response.addHeader("Strict-Transport-Security", "max-age=15768000");
      }

If you also deliver static content, you may want to enable the HSTS header here as well. An example stanza within your appengine-web.xml file might look like this.

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
...
    <static-files>
    <include path="/static/**" >
      <http-header name="Strict-Transport-Security" value="max-age=15768000"/>
...



If you're on a custom domain, you can use either SNI or a VIP. Details here. You'll need to upload your SSL cert files to the Google Apps control panel for your domain, then add and configure SNI or VIP slots in App Engine.

nginx

We can setup nginx to listen on port 443 with our SSL sertificate quite easily:

server {
    listen 443 ssl;
    server_name example.org;

     ssl_certificate /path/to/unified.crt;
     ssl_certificate_key /path/to/my-private-decrypted.key;

     //usual nginx config here like location blocks
}

For more detailed nginx config instructions see the page on nginx

Test

Production

Le Test Serveur de Qualys est un moyen facile de tester le certificat SSL sur votre site. Voir par exemple la carte de compte-rendu pour brid.gy, ou en comparaison celle de jonnybarnes.uk qui a des résultats légèrement différents.

shaaaaaaaaaaaaa.com vérifiera si votre SSL Cert utilise SHA-1 ou SHA-2 et explique pouquoi ça devient de plus en plus important.

https://securityheaders.io testera la dureté d'en-tête de sécurité du serveur web et offre des raisons

Observatory par Mozilla vérifie différents aspects de sécurité d'un site et donne un score, en plus d'agréger les résultats à partir de tiers qui scannent les sites tels que https://securityheaders.io.

testssl.sh est un script ligne de commande qui peut tourner localement pour vérifier les certificats et configurations TLS.

Vous pouvez utiliser openssl s_client pour debuger les problèmes de connexion, par exemple :

openssl s_client -connect snarfed.org:443

If your server uses SNI, you'll need to provide the hostname too:

openssl s_client -servername www.brid.gy -connect www.brid.gy:443

Here's an example of debugging a single SSL issue:

Brand new StartSSL certificates may give an OCSP validation error for 6-24 hours after purchase. This seems to only affect Firefox and resolves itself when the certificate propagates to the validation server[2]. Firefox users can disable the check temporarily with Edit > Preferences > Advanced > Certificates > Validation, and uncheck "Use the Online Certificate Status Protocol"

Local

When developing a website locally, it may be useful to be able to test the site via https. For example, when writing an OAuth client, some providers will not redirect to a page that does not use https.

The easiest way to do this is to temporarily redirect your site to your own localhost (just for yourself) and use your site's cert. Just add a line like this to your hosts file:

127.0.0.1	snarfed.org

This is obviously temporary, though. For a more permanent setup, you can either generate a self-signed SSL certificate for your testing domain (localhost, etc) or you can create your own SSL certificate authority and sign the certificate with that.

To assist with this, aaronpk has created an "IndieWebCamp" root authority that can sign certificates for domains ending in ".dev".

You can add a line to your hosts file for your test domain such as

127.0.0.1   mydomain.dev

And then you can use the IndieWebCamp certificate authority to generate an SSL cert for it.

Renew

A few things to be aware of when you need to renew your certificates.

Because all of the browsers now share lists of certificates that are invalid and/or broken as part of OCSP stapling you should renew your certificate at least two days prior to it expiring and then update your server with the certificate at least a day before. This allows the various OCSP lists to update before you touch your server - if you do not you may get some customers whose browsers have an older list and your certificate will not pass their OCSP check, which is different than it being on the revocation list.

Let's Monitor is a free service to monitor your sites and alert you via SMS or email when your certificates are out of date or aren't working.

Trucs, astuces et bonnes pratiques

  • pour éviter des alertes de contenus mixés, remplacez chaque lien entrant http:// et https:// ( votre domaine ) vers seulement le préfixe // . Ceci est supporté dans tous les navigateurs modernes et retrouvera automatiquement le protocole quand vous voudrez accéder à la page.

Posts concernant HTTPS

Niveaux IndieMark

Les niveaux IndieMark du support HTTPS recommandé pour votre propre site web, en tant que partie du composant sécurité


Niveau 1 sécurité

Niveau 1 - Don't do the wrong thing. (what's the minimal "not wrong thing"?). Possible reasonable behaviors:

  • Refuser la connexion, parce que si vous ne support pas SSL, généralement vous n'écoutez pas le 443, ainsi les clients ne peuvent pas se connecter. Défi : l'utilisateur n'a pas idée de ce qui ne va pas, ni la façon de corriger ça (c'est à dire essayer de nouveau le site avec "http:").

Pourquoi ?

  • Éviter une expérience-utilisateur trompeuse.

Exemples IndieWeb

  • ... ajoutez-vous ici vous-même avec la date de votre Niveau 1 vérifié !


Niveau 2 sécurité

Niveau 2 - Sécurisez l'admin de votre site - supporter https pour vos pages d'UI de connexion/admin avec un certificat auto-signé.

  • Vos page(s) admin :
    1. DOIVENT être disponible sur https
    2. DEVRAIENT rediriger automatiquement de http à https, afin que vous ne vous connectiez pas accidentellement en clair sur http (c'est à dire envoyer vos identifiants login et mot de passe de votre site en clair)
    3. DEVRAIT inclure le marqueur de sécurité (détails PHP) au moment de régler les cookies de session/credential, de telle façon que les cookies ne fuirent pas sur d'autres (probablement non-admin) requêtes http (c'est à dire permettre les attaques de réutilisation de cookie style Firesheep)

Pourquoi ?

  • Sécurité pour l'accès-en-écriture pour votre site ! Autrement n'importe qui peut hacker votre CMS et poster des choses à votre place (par exemple utiliser un outil comme Firesheep pour aspirer vos cookies de connexion de session, et les ré-utiliser pour avoir accès à vos pages admin.

Comment faire

  1. How to make your admin page(s) available over https:
    1. install a self-signed certificate (see your webhosting provider for details)
    2. navigate explicitly (e.g. by typing) to the https:// version of your site.
  2. How to redirect your admin UI from http to https automatically:
    1. make Wordpress Admin use SSL: http://codex.wordpress.org/Administration_Over_SSL
    2. make your own other software use SSL on Apache using .htaccess (derived from that WP reference), e.g. for your admin URL example.com/my-adm/

      # HTTPS-only my-adm
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC]
      RewriteCond %{HTTPS} !=on [NC]
      RewriteRule ^/?(my-adm/) https://example.com%{REQUEST_URI}%{QUERY_STRING} [R=301,QSA,L]

      where:
      1. example.com is your personal domain, and
      2. my-adm/ is the path to your login / admin web UI.

N.B. useful htaccess file checker: htaccess checker - let's you paste in your htaccess file and test URL flow through it using sample URLs.

  1. How to secure your cookies, e.g. in PHP:
    1. set various session params before calling session_start() :

      ini_set("session.cookie_httponly", 1);
      ini_set("session.use_only_cookies", 1);
      ini_set("session.cookie_secure", 1);
      session_start();

    2. clear your cookies in your browser, use your login flow to sign-into your website, then double check your cookies are secure, e.g. in Firefox:
      1. choose Preferences... from the Firefox menu.
      2. click Privacy tab
      3. click Show Cookies...
      4. enter your domain name into the dialog's search box
      5. select the cookie your code set, e.g. "PHPSESSID"
      6. The info below the list of cookies should say:

        Send For: Encrypted connections only

        If it doesn't, or if it says something like

        Send For: Any type of connection

        then the cookie is not secure.


Note: If you actually setup a real SSL cert for your whole domain and serve your admin interface from the same domain, you have actually achieved Level 3.

IndieWeb Examples


Niveau 3 sécurité

Niveau 3 - Servez facultativement sur toutes vos pages - provide your front-end over both http and https with a cert from a trusted CA, but not necessarily external content, thus you might still get mixed-content warnings sometimes.

Why?

  • You can link from silo profiles to your site via https
  • You can start using (requiring!) your https URL for IndieAuth logins (e.g. into the wiki)
  • Your readers can securely access your site without a scary warning message pop-up.
  • privacy for your readers (what they are choosing to read)[3]

Exemples IndieWeb

Exemples IndieWeb avec http vers des redirections https (qui ont encore besoin d'être réparées d'alertes de contenus mélangés) - nous recommandons explicitement de ne pas rediriger vos pages http vers https à moins que vous ne soyez sûr de ne pas avoir d'alertes de contenus mixés.

  • 2014-??-?? Indiewebcamp.com itself

Niveau 4 sécurité

Niveau 4 - Icône verrou ou mieux au moment de servir https - soyez certain qu'il y ait au moins une icône de cadenas prêt du https dans la barre d'adresse. Servez tout (page d'accueil, permaliens, images) sur https quand l'utilisateur requête https. Éliminez les alertes de contenus mixés (par ex un triangle avec un point d'exclamation prêt du https dans la barre d'URL).

Pourquoi ?

  • Eviter de montrer au lecteur un message d'alerte ou une icône de triangle dans la barre d'adresse du navigateur.
  • Si vous permettez l'accès http ou https à votre site, et que votre accès https *manque* le message d'avertissement de contenu mixé, vous aidez au moins vos visiteurs https.
  • Eliminer les avertissements de contenu-mixé est important parce que ces avertissements rendent le https inefficace. L'utilisateur n'a pas d'idée combien une page, ses images, scripts ou textes créés à partir des scripts viennent d'une connexion encapsulate http.
  • Eviter le contenu http/https qui est bloqué par défaut sur Firefox & Chrome. Voir : https://blog.mozilla.org/security/2013/05/16/mixed-content-blocking-in-firefox-aurora/, https://code.google.com/p/chromium/issues/detail?id=81637

Exemples IndieWeb par ordre d'implémentation


FAQ :
Comment vous assurez-vous que le contenu externe est sur https ? c'est à dire si j'ai un avatar pour un commentaire de portrait Tantek Çelik il sera sur http parce qu'il utilise http.

  • Quand vous recevez une web mention, téléchargez l'image provenant de la h-card et servez-la sur votre propre serveur.
  • Alternativement, utilisez un proxy https d'image comme https://github.com/atmos/camo (utilisé par GitHub)
  • A moins que ce ne soit une mention Twitter, auquel cas liez vers :
    • https://twitter.com/nomutilisateur/image_profil
    • Voir Twitter#Profile_Image_URLs pour en savoir plus sur les images de profil Twitter.

Niveau 5 sécurité

Level 5 - Redirect everything to https - send redirects from http -> https. I.e. your pages automatically always get at least a lock icon in the browser address bar (and no warnings).

Why?

  • All your site URLs will be consistent.
  • Users will more likely get content that you intended to serve them
  • All the advantages to broader internet security of always serving https (documented in intro at top)

IndieWeb Examples in rough order of implementation

  • 2014-??-?? Ryan Barrett on https://snarfed.org/ (via HSTS header)
  • 2014-05-23 Kartik Prabhu on https://kartikprabhu.com/ (via 301 redirect)
  • David Shanske on https://david.shanske.com/ since 2014-12-25.
    • At Level 3 from 2014-08-29
    • Was at Level 4 for a bit, but did not note date.
    • All posts, resources, including external user pics.
    • Caveat: There may be some older posts with embedded images from http that still give the mixed content warning. I think I have them all
      • Dropped down to B...updated ciphers and added a custom DHE parameter. As of 2016-02-14 am back at A+.
  • 2015-06-19 Scott Gruber on https://scottgruber.me Installed renewal cert on 2016-04-18.
  • ...
  • ... add yourself here with the date you reached Level 5!

Check the browser's address bar where your URL is displayed and make sure:

  1. There's a lock icon before (in front of) the URL in the address bar
  2. There's no warning triangle icon (in front of) the URL in the address bar

Why is my site running so slowly?

  • I found that moving my https redirect into httpd instead of .htaccess, and explicitly setting it to go to www meant it would be faster and wouldn't go through multiple redirects. This SO question came in handy for getting httpd to redirect. ~ Shane Hudson

Why am I only A not A+?

Niveau 6 sécurité

Level 6 - Correct ciphers, support forward secrecy, etc. per https://www.ssllabs.com/ssltest/ (all previous levels required, i.e. document method of http to https redirection)

Why?

IndieWeb Examples

Crittique

Legacy Software and SNI Support

A server has an IP address. It used to be that each server would host one website (domain) in HTTP/1. Then HTTP/1.1 introduced the Host header which allowed a server to host multiple domains. However, the connection needs to be encrypted before the Host header can be sent. So which certificate should the server send initially? When the wrong one is chosen we get issues. The solution to this problem is called Server Name Indication. SNI is supported by all modern browsers and cryptography libraries. OpenSSL is one of the most popular and has supported SNI since 2010 for example. However, we can run into issues when older software tries to interact with your site: http://indiewebcamp.com/irc/2015-12-06/line/1449416119493

General X509 Criticism

Taxe de maintenance et fragilité du site

Adding HTTPS to your site adds the extra maintenance tax of HTTPS certificate renewal (and updating).

As a result, if you fail to do this, or get it wrong, your site goes down.

Evidence:

Let’s Encrypt are trying to fix this by making updating TLS certificates an automated process via their Let’s Encrypt client.

En rapport

Sessions

Sessions at IndieWebCamps about https:


Voir aussi