Squid-Kit-TLS-CA Rocky

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Content Scan

  • Auf dem Client muss das CA Zertifikat des Proxy installiert sein.
  • Proxy generiert für jede Anfrage ein neues Zertifikat und schickt es dem Client.
  • Client denkt er kommuniziert mit dem Original Server
  • Virenscan ist möglich
  • Webserver denkt die Anfrage kommt von einem normalen Client
  • Prinzip der Man in the Middle Attacke

Installation von squid

Bei Rocky Linux ist OpenSSL-Unterstützung bereits im Standard-Paket enthalten
  • dnf install -y squid policycoreutils-python-utils

Firewall für squid freischalten

  • firewall-cmd --zone=public --add-service=squid --permanent
  • firewall-cmd --reload

Erstellen eines Selbstsignierten Zertifikates

Verzeichnis anlegen
  • mkdir /etc/squid/certs
  • cd /etc/squid/certs
Generieren Sie ein lokales selbstsigniertes CA-Zertifikat und geheimen Schlüssel (in derselben Datei)
  • openssl req -new -newkey rsa:4096 -sha256 -days 365 -nodes -x509 -keyout squid_proxyCA.pem -out squid_proxyCA.pem -subj "/CN=proxy-ca"
  • chown -R squid:squid squid_proxyCA.pem
  • chmod 0400 squid_proxyCA.pem
Wir extrahieren das ca.crt aus der PEM-Datei
  • openssl x509 -inform PEM -in squid_proxyCA.pem -out squid_proxyCA.crt
Zertifikat dem System hinzufügen, damit es standardmäßig vertrauenswürdig ist
  • cp squid_proxyCA.crt /etc/pki/ca-trust/source/anchors/
  • update-ca-trust

Zertifikat auf den Clients installieren

!!!Wichtig Wichtig Wichtig!!!

  • squid_proxyCA.crt auf die Clients kopieren.
Firefox
  • Burgermenu
    • Einstellungen
      • Nach Zertifikaten suchen
        • Zertifikate anzeigen
          • Zertifizierungsstellen importieren
Zertifikat dem System hinzufügen, damit es standardmäßig vertrauenswürdig ist
  • sudo cp squid_proxyCA.crt /etc/pki/ca-trust/source/anchors/
  • sudo update-ca-trust


Zertifikats Cache anlegen

security_file_certgen — SSL certificate generator for Squid.
  • Das Generieren und Signieren von SSL-Zertifikaten nimmt Zeit in Anspruch.
  • Squid kann diesen Helfer als externen Prozess verwenden, um die Arbeit zu erledigen.
  • Die Kommunikation erfolgt über TCP-Sockets, die an die Loopback-Schnittstelle gebunden sind.
  • Dieser Helfer kann einen Festplattencache mit Zertifikaten verwenden, um die Antwortzeiten bei wiederholten Anforderungen zu verbessern.
  • Es kann auch ohne Cache arbeiten und generiert bei jeder Anfrage neue Zertifikate.
Cache initialisieren
  • chown squid:squid /var/spool/squid
  • sudo -u squid /usr/lib64/squid/security_file_certgen -c -s /var/spool/squid/ssl_db -M 4MB

Einfügen in der squid.conf

  • cat /etc/squid/squid.conf
acl localnet src 0.0.0.1-0.255.255.255	
acl localnet src 10.0.0.0/8		
acl localnet src 100.64.0.0/10		
acl localnet src 169.254.0.0/16 	
acl localnet src 172.16.0.0/12		
acl localnet src 192.168.0.0/16	
acl localnet src fc00::/7       	
acl localnet src fe80::/10      	
acl SSL_ports port 443
acl Safe_ports port 80		
acl Safe_ports port 21		
acl Safe_ports port 443	
acl Safe_ports port 70		
acl Safe_ports port 210	
acl Safe_ports port 1025-65535	
acl Safe_ports port 280	
acl Safe_ports port 488	
acl Safe_ports port 591	
acl Safe_ports port 777	
acl it213 src 10.88.213.0/24
acl it213 src 172.26.213.0/24
acl it213 src 10.213.1.0/24
http_access allow it213
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny to_localhost
http_access deny to_linklocal
http_access deny all
http_port 3128 ssl-bump cert=/etc/squid/certs/squid_proxyCA.pem generate-host-certificates=on options=NO_SSLv3,NO_TLSv1,NO_TLSv1_1
ssl_bump bump all
coredump_dir /var/spool/squid
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320

Start von Squid

  • systemctl enable squid --now

Misc

Hier ist ein Befehl, um die am häufigsten zwischengespeicherten Domänen anzuzeigen.
  • awk 'BEGIN {FS="[ ]+"}; {print $7}' < /var/log/squid/access.log | awk 'BEGIN {FS="/"}; {print $3}' | sort | uniq -c |sort -k1,1nr -k2,2 | head