Lighttpd_SSL.mdwn 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. If you followed the [[tools/systems/admin-guides/SSL]] guide, you probably want
  2. your website to use the certificate you generated. And even if you don't run a
  3. website, but some other service, you want to make the revocation list and the
  4. CA policy page available.
  5. You can also make the CA certificate available on your website, but that's not
  6. the point of this guide. You could also give it to friends on USB sticks or
  7. publish it as a torrent or anything like that. What you really need on the
  8. server side is:
  9. 1. Revocation list
  10. 2. Policy page
  11. 3. Server key
  12. 4. Server certificate
  13. If some information is missing from this page, you can probably find it in
  14. lighttpd's documentation, which is more thorough:
  15. [here](https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_SSL)
  16. In the SSL guide, the examples set the revocation list to be at the address
  17. <http://cert.partager.null/partager-ca-crl.pem>. Assuming you didn't use a
  18. "cert" subdomain until now, it requires that you update your DNS records (add an
  19. A record for the "cert" subdomain). Then, in the lighttpd config file
  20. `/etc/lighttpd/lighttpd.conf` add a section like this:
  21. ## cert host
  22. $HTTP["host"] == "cert.partager.null" {
  23. server.document-root = "/var/www/cert"
  24. }
  25. Then place the revocation list inside the document root folder, e.g.
  26. `/var/www/cert/partager-ca-crl.pem`.
  27. The policy page is just a regular page on your website, at the address you
  28. specified when creating the CA. I use ikiwiki and the page is
  29. <http://www.partager.null/ssl>, so I have an *ssl.mdwn* file on the top-level of
  30. my ikiwiki source repository.
  31. Some servers take the server key and the server certificate as two separate
  32. files. But lighttpd doesn't. It takes a single file which is a concatenation of
  33. them. The order doesn't matter. You can use a command like this to create the
  34. concatenated file:
  35. cat host.key host.crt > host.pem
  36. Place the resulting PEM file in the folder `/etc/ssl/private` (it's not critical
  37. but having all the keys in one folder makes managing them easier). I usually
  38. name these files `<host>.pem`, for example `www.partager.null.pem`. Make the
  39. file readable obly, only by root. These commands can do that:
  40. # chown root:root www.partager.null.pem
  41. # chmod 400 www.partager.null.pem
  42. If you want your website to use *only* SSL, you can put lines like these in the
  43. main configuration file:
  44. ssl.engine = "enable"
  45. ssl.pemfile = "/etc/ssl/private/www.partager.null.pem"
  46. You may also need to set the server port to 443.
  47. If you want to support both HTTP and HTTPS, you can use `$SERVER["socket"]` to
  48. make lighttpd enable SSL conditionally. For example:
  49. $SERVER["socket"] == ":443" {
  50. ssl.engine = "enable"
  51. ssl.pemfile = "/etc/ssl/private/www.partager.null.pem"
  52. $HTTP["host"] == "www.partager.null" {
  53. ssl.pemfile = "/etc/ssl/private/www.partager.null.pem"
  54. }
  55. $HTTP["host"] == "git.partager.null" {
  56. ssl.pemfile = "/etc/ssl/private/git.partager.null.pem"
  57. }
  58. $HTTP["host"] == "files.partager.null" {
  59. ssl.pemfile = "/etc/ssl/private/files.partager.null.pem"
  60. }
  61. }
  62. The *ssl.pemfile* at the top is the default one used when the *host* is not
  63. matched by the `$HTTP["host"]` clauses. It will probably not be used if you
  64. define a pemfile for each host you have, but a default pemfile still must be
  65. defined.
  66. Now restart the server:
  67. # service lighttpd restart
  68. Try browsing to your website using HTTPS. If you haven't told your computer
  69. and/or your browser to trust your CA, some browers will display a warning while
  70. others will load the webpage but signify somehow that the certificate is not
  71. authenticated, e.g. by displaying an open lock image. Firefox derivatives will
  72. display an error, while Epiphany and Midori will load the page.
  73. After this initial test with the browser, you can go to the
  74. [[tools/systems/user-guides]] section and learn how a client is configured to
  75. trust your CA. Follow the guidelines, and test HTTPS again. You may need to
  76. close and reopen the browser. If you see a closed lock icon and no complaints
  77. from the browser, you have successfuly managed to add SSL support to your web
  78. server.
  79. [[!img https.png class="center"]]