Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
centos:web_c7:apache_2 [28.11.2016 16:29. ] – [Zertifikatserstellung] django | centos:web_c7:apache_2 [02.02.2018 09:39. ] (aktuell) – Löschen von falschen HPKP-Daten beim Browser Firefox django | ||
---|---|---|---|
Zeile 263: | Zeile 263: | ||
===== Dokumentation ===== | ===== Dokumentation ===== | ||
==== Fachliteratur ==== | ==== Fachliteratur ==== | ||
- | Das Buch **[[https:// | + | <WRAP center round tip 90%> |
+ | Das Buch **[[https:// | ||
+ | |||
+ | Also alles in allem sehr gut angelegte 55€ - das Buch **978-1-907117-04-6** (ISBN) ist in jedem gut sortierten Buchhandel vor Ort erhältlich sein sollte. | ||
+ | </ | ||
+ | |||
==== Seiten im WWW ==== | ==== Seiten im WWW ==== | ||
Zeile 625: | Zeile 630: | ||
1.0.1e | 1.0.1e | ||
</ | </ | ||
+ | |||
+ | ==== Apache.org ==== | ||
+ | Viele wervolle Hinweise zu den Konfigurationsparameter zu **mod_ssl** findet man in der Dokumentation zum [[http:// | ||
+ | |||
+ | |||
===== CA Trust ===== | ===== CA Trust ===== | ||
Dreh- und Angelpunkt bei den CAs und den zugehörigen Root-Zertifikaten ist das Vertrauen, welches man diesen schenken ma und/oder kann. Mit sehr hoher Wahrscheinlichkeit kann man davon ausgehen dass eine CA wie z.B. **[[https:// | Dreh- und Angelpunkt bei den CAs und den zugehörigen Root-Zertifikaten ist das Vertrauen, welches man diesen schenken ma und/oder kann. Mit sehr hoher Wahrscheinlichkeit kann man davon ausgehen dass eine CA wie z.B. **[[https:// | ||
Zeile 1511: | Zeile 1521: | ||
Im folgenden Schritt zu unserem eigenen Zertifikat erzeugen wir einen **CSR**((**C**ertificate **S**igning **R**equest)), | Im folgenden Schritt zu unserem eigenen Zertifikat erzeugen wir einen **CSR**((**C**ertificate **S**igning **R**equest)), | ||
- | <WRAP round alert> **__Wichtig__**: | + | <WRAP round alert> **__Wichtig__**: |
Auch hier sind die Eingaben in der Farbe < | Auch hier sind die Eingaben in der Farbe < | ||
Zeile 1826: | Zeile 1836: | ||
# chmod 400 / | # chmod 400 / | ||
+ | ===== Konfiguration ===== | ||
+ | ==== ssl.conf ==== | ||
+ | Bei der Konfiguration unseres TLS-gesicherten Apache-Webservers benutzen wir nun nicht die (komplette) mitgelieferte Konfigurationsdatei // | ||
+ | Wir sichern dazu erst einmal die originale Konfigurationsdatei. | ||
+ | # cp -a / | ||
+ | Im ersten Schritt werden wir nun bestehende Konfigurationsdatei soweit " | ||
+ | # vim / | ||
+ | <file bash / | ||
+ | # When we also provide SSL we have to listen to the | ||
+ | # the HTTPS port in addition. | ||
+ | # | ||
+ | Listen 443 https | ||
+ | ## | ||
+ | ## SSL Global Context | ||
+ | ## | ||
+ | ## All SSL configuration in this context applies both to | ||
+ | ## the main server and all SSL-enabled virtual hosts. | ||
+ | ## | ||
+ | # Pass Phrase Dialog: | ||
+ | # | ||
+ | # The filtering dialog program (`builtin' | ||
+ | # | ||
+ | SSLPassPhraseDialog exec:/ | ||
- | ===== Konfiguration ==== | + | # |
- | Viele wervolle Hinweise zu den Konfigurationsparameter findet man in der Dokumentation zum [[http:// | + | # |
+ | # to use and second the expiring timeout (in seconds). | ||
+ | SSLSessionCache | ||
+ | SSLSessionCacheTimeout | ||
- | http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslciphersuite | + | # |
+ | # | ||
+ | # SSL library. The seed data should be of good random quality. | ||
+ | # | ||
+ | # is available. This means you then cannot use the /dev/random device | ||
+ | # | ||
+ | # it requires to make more entropy available). But usually those | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | SSLRandomSeed startup file:/ | ||
+ | SSLRandomSeed connect builtin | ||
+ | #SSLRandomSeed startup file:/ | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Use " | ||
+ | # accelerators. Use " | ||
+ | # engine names. | ||
+ | # server does not start, consult the error logs and ensure | ||
+ | # your accelerator is functioning properly. | ||
+ | # | ||
+ | SSLCryptoDevice builtin | ||
+ | # | ||
+ | ## | ||
+ | ## SSL Virtual Host Context | ||
+ | ## | ||
+ | #< | ||
+ | # | ||
+ | ## General setup for the virtual host, inherited from global configuration | ||
+ | ## | ||
+ | ## | ||
+ | # | ||
+ | ## Use separate log files for the SSL virtual host; note that LogLevel | ||
+ | ## is not inherited from httpd.conf. | ||
+ | #ErrorLog logs/ | ||
+ | # | ||
+ | #LogLevel warn | ||
+ | # | ||
+ | ## SSL Engine Switch: | ||
+ | ## | ||
+ | #SSLEngine on | ||
+ | # | ||
+ | ## SSL Protocol support: | ||
+ | ## List the enable protocol levels with which clients will be able to | ||
+ | ## connect. | ||
+ | # | ||
+ | # | ||
+ | ## SSL Cipher Suite: | ||
+ | ## List the ciphers that the client is permitted to negotiate. | ||
+ | ## See the mod_ssl documentation for a complete list. | ||
+ | # | ||
+ | # | ||
+ | ## | ||
+ | ## If speed is your main concern (on busy HTTPS servers e.g.), | ||
+ | ## you might want to force clients to specific, performance | ||
+ | ## | ||
+ | ## to the SSLCipherSuite list, and enable SSLHonorCipherOrder. | ||
+ | ## | ||
+ | ## (as in the example below), most connections will no longer | ||
+ | ## have perfect forward secrecy - if the server' | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | # | ||
+ | ## | ||
+ | ## Point SSLCertificateFile at a PEM encoded certificate. | ||
+ | ## the certificate is encrypted, then you will be prompted for a | ||
+ | ## pass phrase. | ||
+ | ## certificate can be generated using the genkey(1) command. | ||
+ | # | ||
+ | # | ||
+ | ## | ||
+ | ## If the key is not combined with the certificate, | ||
+ | ## | ||
+ | ## | ||
+ | ## both in parallel (to also allow the use of DSA ciphers, etc.) | ||
+ | # | ||
+ | # | ||
+ | ## | ||
+ | ## Point SSLCertificateChainFile at a file containing the | ||
+ | ## | ||
+ | ## | ||
+ | ## the referenced file can be the same as SSLCertificateFile | ||
+ | ## when the CA certificates are directly appended to the server | ||
+ | ## | ||
+ | ## | ||
+ | # | ||
+ | ## | ||
+ | ## Set the CA certificate verification path where to find CA | ||
+ | ## | ||
+ | ## huge file containing all of them (file must be PEM encoded) | ||
+ | ## | ||
+ | # | ||
+ | ## | ||
+ | ## | ||
+ | ## none, optional, require and optional_no_ca. | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | # | ||
+ | ## | ||
+ | ## With SSLRequire you can do per-directory access control based | ||
+ | ## on arbitrary complex boolean expressions containing server | ||
+ | ## | ||
+ | ## | ||
+ | ## for more details. | ||
+ | ##< | ||
+ | ## | ||
+ | ## and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \ | ||
+ | ## and %{SSL_CLIENT_S_DN_OU} in {" | ||
+ | ## and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \ | ||
+ | ## and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \ | ||
+ | ## or %{REMOTE_ADDR} =~ m/ | ||
+ | ##</ | ||
+ | # | ||
+ | ## SSL Engine Options: | ||
+ | ## Set various options for the SSL engine. | ||
+ | ## o FakeBasicAuth: | ||
+ | ## | ||
+ | ## the standard Auth/ | ||
+ | ## user name is the `one line' version of the client' | ||
+ | ## Note that no password is obtained from the user. Every entry in the user | ||
+ | ## file needs this password: `xxj31ZMTZzkVA' | ||
+ | ## o ExportCertData: | ||
+ | ## This exports two additional environment variables: SSL_CLIENT_CERT and | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## into CGI scripts. | ||
+ | ## o StdEnvVars: | ||
+ | ## This exports the standard SSL/TLS related `SSL_*' | ||
+ | ## Per default this exportation is switched off for performance reasons, | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## o StrictRequire: | ||
+ | ## This denies access when " | ||
+ | ## under a " | ||
+ | ## and no other module can change it. | ||
+ | ## o OptRenegotiate: | ||
+ | ## This enables optimized SSL connection renegotiation handling when SSL | ||
+ | ## | ||
+ | ## | ||
+ | #<Files ~ " | ||
+ | # SSLOptions +StdEnvVars | ||
+ | #</ | ||
+ | #< | ||
+ | # SSLOptions +StdEnvVars | ||
+ | #</ | ||
+ | # | ||
+ | ## SSL Protocol Adjustments: | ||
+ | ## The safe and default but still SSL/TLS standard compliant shutdown | ||
+ | ## | ||
+ | ## the close notify alert from client. When you need a different shutdown | ||
+ | ## | ||
+ | ## o ssl-unclean-shutdown: | ||
+ | ## This forces an unclean shutdown when the connection is closed, i.e. no | ||
+ | ## SSL close notify alert is send or allowed to received. | ||
+ | ## the SSL/TLS standard but is needed for some brain-dead browsers. Use | ||
+ | ## this when you receive I/O errors because of the standard approach where | ||
+ | ## | ||
+ | ## o ssl-accurate-shutdown: | ||
+ | ## This forces an accurate shutdown when the connection is closed, i.e. a | ||
+ | ## SSL close notify alert is send and mod_ssl waits for the close notify | ||
+ | ## alert of the client. This is 100% SSL/TLS standard compliant, but in | ||
+ | ## | ||
+ | ## this only for browsers where you know that their SSL implementation | ||
+ | ## works correctly. | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## | ||
+ | ## their broken HTTP/1.1 implementation. Use variables " | ||
+ | ## " | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | ## | ||
+ | ## The home of a custom SSL log file. Use this when you want a | ||
+ | ## | ||
+ | #CustomLog logs/ | ||
+ | # "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | ||
+ | # | ||
+ | #</ | ||
+ | </ | ||
+ | |||
+ | Die Hauptkonfiguration beschrängt sich demnach auf folgende sieben Zeilen: | ||
+ | # egrep -v ' | ||
+ | |||
+ | <code bash> | ||
+ | SSLPassPhraseDialog exec:/ | ||
+ | SSLSessionCache | ||
+ | SSLSessionCacheTimeout | ||
+ | SSLRandomSeed startup file:/ | ||
+ | SSLRandomSeed connect builtin | ||
+ | SSLCryptoDevice builtin</ | ||
+ | |||
+ | |||
+ | ==== vHost.conf ==== | ||
+ | |||
+ | # vim / | ||
+ | <file apache / | ||
+ | # Django : 2015-10-30 | ||
+ | # vHost hk-forum | ||
+ | # | ||
+ | |||
+ | # Variablen der Hostvariablen | ||
+ | Define vhost hk-forum | ||
+ | Define errors_log logs/ | ||
+ | Define access_log logs/ | ||
+ | Define ssl_log logs/ | ||
+ | |||
+ | < | ||
+ | ServerAdmin webmaster@nausch.org | ||
+ | ServerName ${vhost}.nausch.org | ||
+ | |||
+ | RewriteEngine on | ||
+ | RewriteCond %{HTTPS} off | ||
+ | RewriteRule (.*) https:// | ||
+ | |||
+ | # Welche Logdateien sollen beschrieben werden | ||
+ | SetEnvIf Remote_Addr " | ||
+ | ErrorLog | ||
+ | CustomLog ${access_log} combined env=!dontlog | ||
+ | </ | ||
+ | < | ||
+ | ServerAdmin webmaster@nausch.org | ||
+ | ServerName ${vhost}.nausch.org | ||
+ | ServerPath / | ||
+ | |||
+ | # Wer soll Zugriff auf die Webseite(n) bekommen? | ||
+ | #< | ||
+ | # Options +FollowSymLinks +Multiviews -Indexes | ||
+ | # AllowOverride None | ||
+ | # AuthType Basic | ||
+ | # AuthName "Fuer den Zugriff auf den Webserver bitte Anmeldedaten eingeben!" | ||
+ | # AuthBasicProvider ldap | ||
+ | # AuthLDAPUrl ldaps:// | ||
+ | # AuthLDAPBindDN cn=Technischeruser, | ||
+ | # AuthLDAPBindPassword " | ||
+ | # AuthLDAPBindAuthoritative on | ||
+ | # Require ldap-user accessuser | ||
+ | #</ | ||
+ | |||
+ | # Welcher Inhalt soll angezeigt bzw. auf welchen Server sollen die HTTP-Requests | ||
+ | # | ||
+ | DocumentRoot | ||
+ | DirectoryIndex index.php | ||
+ | |||
+ | < | ||
+ | Options none | ||
+ | AllowOverride Limit | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Require all denied | ||
+ | </ | ||
+ | |||
+ | # Welche Logdateien sollen beschrieben werden | ||
+ | SetEnvIf Remote_Addr " | ||
+ | ErrorLog | ||
+ | CustomLog ${access_log} combined env=!dontlog | ||
+ | CustomLog ${ssl_log} "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | ||
+ | |||
+ | # Absicherung der Übertragung mit Hilfe von TLS | ||
+ | # Django : 2015-10-04 - TLS-Verschlüsselung mit Hilfe von mod_ssl | ||
+ | SSLEngine on | ||
+ | # Definition der anzubietenden Protokolle | ||
+ | SSLProtocol All -SSLv2 -SSLv3 | ||
+ | # Definition der Cipher | ||
+ | SSLCipherSuite " | ||
+ | # Schlüsseldatei, | ||
+ | SSLCertificateKeyFile / | ||
+ | # Zertifikatsdatei , die von der CA signiert wurde | ||
+ | SSLCertificateFile / | ||
+ | # Zertifikatsdatei des bzw. der Intermediate-Zertifikate(s) | ||
+ | SSLCertificateChainFile / | ||
+ | # Änderung der Cipherorder der Clienets verneinen | ||
+ | SSLHonorCipherOrder on | ||
+ | # TLS 1.0 Kompremmierung deaktivieren (CRIME attacks) | ||
+ | SSLCompression off | ||
+ | # Online Certificate Status Protocol stapling zum Prüfen des | ||
+ | # Gültigkeitsstatus des Serverzertifikats. | ||
+ | SSLUseStapling | ||
+ | SSLStaplingResponderTimeout 5 | ||
+ | SSLStaplingReturnResponderErrors off | ||
+ | # ist in der ssl.conf | ||
+ | # SSLStaplingCache | ||
+ | |||
+ | # special stuff ### | ||
+ | |||
+ | # HTTP Strict Transport Security (HSTS), bei dem der Server dem Client im HTTP-Header | ||
+ | # mitteilt, dass dieser nur noch verschlüsselt mit dem Server kommunizieren soll. | ||
+ | Header always set Strict-Transport-Security " | ||
+ | |||
+ | # This header enables the Cross-site scripting (XSS) filter built into most recent | ||
+ | # web browsers. It's usually enabled by default anyway, so the role of this header | ||
+ | # is to re-enable the filter for this particular website if it was disabled by the | ||
+ | # user. https:// | ||
+ | Header set X-XSS-Protection "1; mode=block" | ||
+ | |||
+ | # when serving user-supplied content, include a X-Content-Type-Options: | ||
+ | # header along with the Content-Type: | ||
+ | # some browsers. https:// | ||
+ | # currently suppoorted in IE > 8 | ||
+ | # http:// | ||
+ | # http:// | ||
+ | # ' | ||
+ | Header set X-Content-Type-Options nosniff | ||
+ | |||
+ | # config to don't allow the browser to render the page inside an frame or iframe | ||
+ | # and avoid clickjacking http:// | ||
+ | # if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with | ||
+ | # ALLOW-FROM uri https:// | ||
+ | header set X-Frame-Options DENY | ||
+ | |||
+ | # hide server header (apache and php version) | ||
+ | Header unset Server | ||
+ | |||
+ | # Only allow JavaScript from the same domain to be run. | ||
+ | # don't allow inline JavaScript to run. | ||
+ | Header set X-Content-Security-Policy "allow ' | ||
+ | |||
+ | # Add Secure and HTTP only attributes to cookies | ||
+ | Header edit Set-Cookie ^(.*)$ $1; | ||
+ | |||
+ | # prevent Clickjacking Attack | ||
+ | #Header always append X-Frame-Options SAMEORIGIN | ||
+ | Header set Content-Security-Policy " | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
FIXME | FIXME | ||
Zeile 2123: | Zeile 2496: | ||
https:// | https:// | ||
+ | https:// | ||
+ | |||
+ | ==== HSTS ==== | ||
+ | |||
+ | |||
+ | In der vHost-Definition unseres Apache-vHOST ergänzen wir folgende Zeile '' | ||
+ | # vim / | ||
+ | |||
+ | <code bash>... | ||
+ | |||
+ | # HTTP Strict Transport Security (HSTS), bei dem der Server dem Client im | ||
+ | # HTTP-Header mitteilt, dass dieser nur noch verschlüsselt mit dem Server | ||
+ | # kommunizieren soll. | ||
+ | Header always set Strict-Transport-Security " | ||
+ | |||
+ | ...</ | ||
+ | |||
+ | ==== OCSP Stapling ==== | ||
+ | |||
+ | In der // | ||
+ | # vim / | ||
+ | <code bash>... | ||
+ | |||
+ | # Django : 2015-11-11 | ||
+ | # Chache-Definition für Online Certificate Status Protocol stapling | ||
+ | SSLStaplingCache " | ||
+ | |||
+ | ...</ | ||
+ | |||
+ | In der vHost-Definition unseres Apache-vHOST ergänzen wir folgende drei Zeilen. | ||
+ | # vim / | ||
+ | |||
+ | <code bash>... | ||
+ | |||
+ | # Online Certificate Status Protocol stapling zum Prüfen des Gültigkeitsstatus | ||
+ | # des Serverzertifikats. | ||
+ | SSLUseStapling | ||
+ | SSLStaplingResponderTimeout 5 | ||
+ | SSLStaplingReturnResponderErrors off | ||
+ | |||
+ | ...</ | ||
+ | |||
+ | |||
+ | $ openssl s_client -connect forum.nausch.org: | ||
+ | < | ||
+ | depth=2 C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA | ||
+ | verify return:1 | ||
+ | depth=1 C = BE, O = GlobalSign nv-sa, CN = AlphaSSL CA - SHA256 - G2 | ||
+ | verify return:1 | ||
+ | depth=0 OU = Domain Control Validated, CN = forum.nausch.org | ||
+ | verify return:1 | ||
+ | OCSP response: | ||
+ | ====================================== | ||
+ | OCSP Response Data: | ||
+ | OCSP Response Status: successful (0x0) | ||
+ | Response Type: Basic OCSP Response | ||
+ | Version: 1 (0x0) | ||
+ | Responder Id: EE5EFFFE85DB26C626FBD3698410AD1D0DD3EF58 | ||
+ | Produced At: Nov 29 18:16:05 2016 GMT | ||
+ | Responses: | ||
+ | Certificate ID: | ||
+ | Hash Algorithm: sha1 | ||
+ | Issuer Name Hash: 84D56BF8098BD307B766D8E1EBAD6596AA6B6761 | ||
+ | Issuer Key Hash: F5CDD53C0850F96A4F3AB797DA5683E669D268F7 | ||
+ | Serial Number: 6922D213277B49AC169E77A9 | ||
+ | Cert Status: good | ||
+ | This Update: Nov 29 18:16:05 2016 GMT | ||
+ | Next Update: Dec 3 18:16:05 2016 GMT | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Werden **__keine__** OCSP-Response Daten angezeigt, ist dies ein Hinweis, dass die OCSP_Konfiguration nnoch nicht richtig abgeschlossen wurde! | ||
+ | |||
+ | Zum Testen kann man alternativ auch den Test bei [[https:// | ||
+ | |||
+ | ==== Secure Cookie mit HttpOnly ==== | ||
+ | |||
+ | In der vHost-Definition unseres Apache-vHOST ergänzen wir folgende Zeile '' | ||
+ | '' | ||
+ | # vim / | ||
+ | |||
+ | <code bash>... | ||
+ | |||
+ | # Add Secure and HTTP only attributes to cookies | ||
+ | Header edit Set-Cookie ^(.*)$ $1; | ||
+ | |||
+ | ...</ | ||
+ | |||
+ | https:// | ||
+ | |||
+ | | set-cookie: | ||
+ | |||
+ | **HttpOnly** und **Secure** kennzeichnen die erfolgreiche Änderung! | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== HPKP ==== | ||
+ | [[https:// | ||
+ | # openssl rsa -pubout -in / | ||
+ | | ||
+ | |||
+ | writing RSA key | ||
+ | nMiOpb6vUnjCoWCkPkDaG4ND8SNWzFTsQf2ZfruLno0= | ||
+ | |||
+ | pin-sha256=" | ||
+ | |||
+ | # openssl rsa -pubout -in / | ||
+ | | ||
+ | |||
+ | writing RSA key | ||
+ | INhxSQ38nCS6ijaAAyo4xAhAZj9xeL3Xaak+GGiM2fo= | ||
+ | |||
+ | Zum Löschen von outdated bzw. falschen key-hashes beim Firefox zuerst einam den Browser stoppen. Anschließend bearbeiten wir die Einträge in der Datei **SiteSecurityServiceState.txt** im profile-Pafd unserer Installation. | ||
+ | # vim ~/ | ||
+ | |||
+ | Nach dem Speichern unserer Änderungen starten wir den Browser neu und können wieder auf die zuvor blockierten Seiten zugreifen. | ||
+ | |||
+ | ===== Tests ===== | ||
+ | |||
+ | Artikel auf [[http:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||