添加 SSL 证书后 RMI+SSL 请求非常慢

添加 SSL 证书后 RMI+SSL 请求非常慢

我在基于RMI的应用程序中添加了SSL证书,并且它在测试服务器上正常工作,因此在将其部署到生产服务器上后,所有请求都在等待SSL握手,即使是本地连接,这是由生产服务器具有的一些iptables规则引起的。

基本上,所有的端口都被阻止,只允许需要的端口。下面是我们执行的默认 iptables 规则/etc/rc.local

#Flush all
iptables -F
iptables -t nat -F

#Chains
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

#Allow local connections
iptables -A INPUT -s localhost -d localhost -j ACCEPT
iptables -A INPUT -s $ip -d $ip -j ACCEPT

#RMI ports (for rmi app)
iptables -A INPUT -p tcp --dport 1826 -j ACCEPT
iptables -A INPUT -p tcp --dport 1827 -j ACCEPT
iptables -A INPUT -p tcp --dport 18026 -j ACCEPT

#allowing RMI socket port range
iptables -A INPUT -p tcp --destination-port 20000:65535 -j ACCEPT

#Allow apache, https, tomcat ports
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp --dport 8443 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

#Allow pings
iptables -A INPUT -p icmp -j ACCEPT

#Allow DNS
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 953 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --dport 953 -j ACCEPT

我对 iptables 规则了解不多,但我认为在 SSL 握手时,某些请求可以发送到 Digicert,或者它使用一些不允许的端口或协议(例如),以及一些缺少的 iptables 规则导致了这种“永恒的等待”。

有人已经遇到过这样的相同或类似问题吗?

信息

服务器:digitalocean 的 CentOS 6.5 x64。应用程序:JVM 1.8,基于 RMI(适用于瘦桌面客户端)和 Tomcat (8080)(适用于 Web 用户)。 Tomcat 连接使用本地 rmi 连接。

更新

添加这些规则的作品:

iptables -A INPUT -s secure.globalsign.com -j ACCEPT
iptables -A INPUT -s ocsp.globalsign.com -j ACCEPT
iptables -A INPUT -s ocsp2.globalsign.com -j ACCEPT
iptables -A INPUT -s crl.globalsign.com -j ACCEPT

不过,握手还是有点慢。

相关内容