AWS EC2 Linux AMI上的Tomcat 8.5 SSL配置

时间:2017-11-22 13:41:07

标签: amazon-ec2 spring-security java-8 ssl-certificate tomcat8

我正在尝试在我的AWS EC2 Linux AMI实例上配置Godaddy SSL证书。但无论我尝试什么,只是拒绝连接。但是我已经在安全组中打开了入站443端口。 我已经在LAMP上配置了好几次,但它第一次在java上配置,所以也许我错过了一些东西?

我按照此Godaddy's tomcat guide在我的实例上设置了SSL。我还阅读了下面的线程来克服这个问题,但仍然没有工作 1. Install SSL on EC2 Server
2. EC2 instance running apache tomcat port 8443 not accessible

这是我遵循的步骤:
这就是我设置tomcat密钥库的方法

keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore

keytool -certreq -keyalg RSA -alias tomcat -file csr.csr -keystore tomcat.keystore

sudo keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file /etc/ssl/WSssl/gd_bundle-g2-g1.crt

sudo keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file /etc/ssl/WSssl/gdig2.crt.pem

sudo keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file /etc/ssl/WSssl/ab51xxxxx79.crt

在tomcat 8.5 server.xml上配置密钥文件

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

<Connector 
       port="8443" maxThreads="200"
       scheme="https" secure="true" SSLEnabled="true"
       keystoreFile="/home/ec2-user/tomcat.keystore" keystorePass="exxxxxxxxxxxxxM"
       clientAuth="false" sslProtocol="TLS" />

要重定向的IP表

sudo iptables -t nat -n -L PREROUTING --line-numbers
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         
1    REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 redir ports 8443
2    REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 8080

这些是安全组入站规则,没有我的ec2实例与任何负载均衡器直接连接 Inbound Rules

这是问题,它拒绝每个Https请求 Refused Error

这是Godaddy证书检查器result

我认为问题在于端口,因为请求甚至没有打到服务器。任何人都可以指出任何问题吗?

为了清楚,这是规范:
在Amazon Linux AMI上运行的AWS EC2,Java 8,Tomcat 8.5用Spring Spring项目的Spring MVC

2 个答案:

答案 0 :(得分:0)

最后,它正在运行,配置本身没有任何问题。在阅读catalina.out时,我发现由于用户权限,tomcat无法读取tomcat.keystore文件。

学习:请务必先阅读日志
编辑:任何人都可以将其用作设置SSL的指南

答案 1 :(得分:-1)

假设您从vpc外部进行连接,则应检查vpc acl是否允许443中的入站和短暂端口的出站。