Squid SSL透明代理

时间:2020-10-21 09:00:03

标签: ssl-certificate squid

那是行不通的,对吗?

安装.pem文件后,Firefox正常,但其他应用程序无法正常工作。

使用{p>将.pem文件转换为.crt

# openssl x509 -outform der -in myCA.pem -out myCA.crt

并在certlm中将其安装为受信任的根证书自发证书 ,但仍然有许多不起作用的地方:Outlook,Teams,GoogleDrive ......

1 个答案:

答案 0 :(得分:0)

这似乎非常不可靠。

这是Squid工作的配置(来自https://elatov.github.io/2019/01/using-squid-to-proxy-ssl-sites/)。我不知道为什么-我只是很幸运。

acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump all
ssl_bump splice all

使用

    在浏览器中
  • .pem作为 Authority ,并且
  • Windows中的.crt作为受信任的根证书颁发机构。

对于例外,最好的方法是不要首先将它们发送给Squid。在-d命令中使用带有域名的iptables标志只是在命令执行时将其解析为IP地址,因此最好保持ipset可以使用的iptables参考。

这是我的脚本,用于使用文本文件中的域维护我的ipset。 这个想法是可以作为cron作业来运行,以获取新域并将地图更新为IP地址。

#!/bin/sh

## Bypass Squid

ipset -L no-proxy >/dev/null 2>&1
if [ $? -ne 0 ]; then
        echo "Creating ipset: no-proxy."
        ipset create no-proxy hash:ip
fi

ipset flush no-proxy

if [ -f "/etc/squid/no-proxy-iptables.txt" ]; then
        for domain in $(cat /etc/squid/no-proxy-iptables.txt); do
                for address in $( dig a $domain +short | grep -P -e '^(\d{1,3}\.){3}\d{1,3}$' ); do
                        echo $domain " -> " $address
                        ipset add no-proxy $address
                done
        done
else
        echo "File doess not exist: /etc/squid/no-proxy-iptables.txt"
fi

这是我的防火墙脚本:

#!/bin/sh

iptables -t nat -F
iptables -t mangle -F
iptables -F # Does NOT flush everything! Hence the other three commands.
iptables -X

# Squid: exceptions
ipset -L no-proxy >/dev/null 2>&1
if [ $? -eq 0 ]; then
        echo "Using ipset: no-proxy."
        iptables -t nat -A PREROUTING -i br0 -m set --match-set no-proxy dst -j ACCEPT
fi

# Squid: HTTP
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j DNAT --to 192.168.1.31:3128
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128

# Squid: HTTPS
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j DNAT --to 192.168.1.31:3129
iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 3129

# IP masquerade

iptables -A FORWARD -o wlan0 -i br0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o enp0s6f1u2 -j MASQUERADE

# echo 1 > /proc/sys/net/ipv4/ip_forward

iptables-save > /etc/iptables/rules.v4

通过留意浏览器开发工具中的网络标签,您似乎可以很好地猜测要绕过的域。