修復 OpenVPN 客戶端上的“TLS 錯誤:TLS 握手失敗”
我正在我的 Arch Linux 伺服器上配置 OpenVPN 2.3.6-1,以便加密公共 Internet 上的 SMB 流量。當我在我的一個 Linux 虛擬機客戶端上測試設置時,我收到錯誤:
TLS Error: TLS handshake failed
.我快速閱讀(OpenVZ TLS 錯誤上的 OpenVPN:TLS 握手失敗(Google建議的解決方案沒有幫助))並嘗試從預設的 UDP 切換到 TCP,但這只會導致客戶端反复報告連接超時。我還嘗試禁用密碼和 TLS 身份驗證,但這會導致伺服器以
Assertion failed at crypto_openssl.c:523
. 在這兩種情況下,都對客戶端和伺服器配置進行了所需的更改。我一直按照(https://wiki.archlinux.org/index.php/OpenVPN)的說明設置 OpenVPN 和(https://wiki.archlinux.org/index.php/Create_a_Public_Key_Infrastructure_Using_the_easy-rsa_Scripts的說明) 創建密鑰和證書。我與這些說明的唯一偏差是指定我自己的電腦名稱及其相應的密鑰/證書文件名。
另請參閱我關於通過 Internet 保護 SMB 流量的原始問題:(Samba 共享的簡單加密)
誰能解釋我如何解決這個問題?
細節:
伺服器:Arch Linux(最新)通過乙太網電纜直接連接到網關。沒有iptables。
客戶端:VirtualBox 4.3.28r100309 Windows 8.1 主機上的 Arch Linux(最新)虛擬機,橋接網路適配器。沒有iptables。Windows 防火牆已禁用。
網關:啟用埠 1194 的埠轉發,沒有防火牆限制。
這里分別是伺服器和客戶端上的配置文件。我根據 Arch Wiki 上的說明創建了這些。
/etc/openvpn/server.conf
(僅限非註釋行):port 1194 proto udp dev tun ca /etc/openvpn/ca.crt cert /etc/openvpn/server-name.crt key /etc/openvpn/server-name.key dh /etc/openvpn/dh2048.pem server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt keepalive 10 120 tls-auth /etc/openvpn/ta.key 0 comp-lzo user nobody group nobody persist-key persist-tun status openvpn-status.log verb 3
/etc/openvpn/client.conf
(僅限非註釋行):client dev tun proto udp remote [my public IP here] 1194 resolv-retry infinite nobind user nobody group nobody persist-key persist-tun ca /etc/openvpn/ca.crt cert /etc/openvpn/client-name.crt key /etc/openvpn/client-name.key remote-cert-tls server tls-auth /etc/openvpn/ta.key 1 comp-lzo verb 3
以下是在具有上述配置的機器上執行 openvpn 的輸出。我先啟動伺服器,然後啟動客戶端。
伺服器上的輸出
openvpn /etc/openvpn/server.conf
:Thu Jul 30 17:02:53 2015 OpenVPN 2.3.6 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Dec 2 2014 Thu Jul 30 17:02:53 2015 library versions: OpenSSL 1.0.2d 9 Jul 2015, LZO 2.09 Thu Jul 30 17:02:53 2015 NOTE: your local LAN uses the extremely common subnet address 192.168.0.x or 192.168.1.x. Be aware that this might create routing conflicts if you connect to the VPN server from public locations such as internet cafes that use the same subnet. Thu Jul 30 17:02:53 2015 Diffie-Hellman initialized with 2048 bit key Thu Jul 30 17:02:53 2015 Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file Thu Jul 30 17:02:53 2015 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Thu Jul 30 17:02:53 2015 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Thu Jul 30 17:02:53 2015 Socket Buffers: R=[212992->131072] S=[212992->131072] Thu Jul 30 17:02:53 2015 ROUTE_GATEWAY 192.168.0.1/255.255.255.0 IFACE=enp5s0 HWADDR=##:##:##:##:##:## Thu Jul 30 17:02:53 2015 TUN/TAP device tun0 opened Thu Jul 30 17:02:53 2015 TUN/TAP TX queue length set to 100 Thu Jul 30 17:02:53 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0 Thu Jul 30 17:02:53 2015 /usr/bin/ip link set dev tun0 up mtu 1500 Thu Jul 30 17:02:53 2015 /usr/bin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2 Thu Jul 30 17:02:53 2015 /usr/bin/ip route add 10.8.0.0/24 via 10.8.0.2 Thu Jul 30 17:02:53 2015 GID set to nobody Thu Jul 30 17:02:53 2015 UID set to nobody Thu Jul 30 17:02:53 2015 UDPv4 link local (bound): [undef] Thu Jul 30 17:02:53 2015 UDPv4 link remote: [undef] Thu Jul 30 17:02:53 2015 MULTI: multi_init called, r=256 v=256 Thu Jul 30 17:02:53 2015 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0 Thu Jul 30 17:02:53 2015 IFCONFIG POOL LIST Thu Jul 30 17:02:53 2015 Initialization Sequence Completed
在客戶端的輸出
openvpn /etc/openvpn/client.conf
:Thu Jul 30 21:03:02 2015 OpenVPN 2.3.6 x86_64-unknown-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [MH] [IPv6] built on Dec 2 2014 Thu Jul 30 21:03:02 2015 library versions: OpenSSL 1.0.2d 9 Jul 2015, LZO 2.09 Thu Jul 30 21:03:02 2015 WARNING: file '/etc/openvpn/client-name.key' is group or others accessible Thu Jul 30 21:03:02 2015 WARNING: file '/etc/openvpn/ta.key' is group or others accessible Thu Jul 30 21:03:02 2015 Control Channel Authentication: using '/etc/openvpn/ta.key' as a OpenVPN static key file Thu Jul 30 21:03:02 2015 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Thu Jul 30 21:03:02 2015 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Thu Jul 30 21:03:02 2015 Socket Buffers: R=[212992->131072] S=[212992->131072] Thu Jul 30 21:03:02 2015 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay Thu Jul 30 21:03:02 2015 UDPv4 link local: [undef] Thu Jul 30 21:03:02 2015 UDPv4 link remote: [AF_INET][my public IP here]:1194 Thu Jul 30 21:04:02 2015 TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity) Thu Jul 30 21:04:02 2015 TLS Error: TLS handshake failed Thu Jul 30 21:04:02 2015 SIGUSR1[soft,tls-error] received, process restarting Thu Jul 30 21:04:02 2015 Restart pause, 2 second(s)
正如 Michael Hampton 和 Michal Sokolowski 在對我的問題的評論中所建議的那樣,這是我在網關上創建的埠轉發規則的問題。OpenVPN 配置為使用 UDP,我忘記在網關上從 TCP 切換到 UDP,因為我通常不使用該協議。轉發規則現在使用 UDP,並且我的 VPN 可以正常工作。
我也有這個問題。
我正在為我的伺服器使用 digitalocean 提供商,問題出在浮動 ip 功能上。
為了解決這個問題,您必須更新 openvpn 配置設置:
local <ip anchor>