【问题标题】:Tomcat 8.5 SSL config on AWS EC2 Linux AMIAWS EC2 Linux AMI 上的 Tomcat 8.5 SSL 配置
【发布时间】:2017-11-22 13:41:06
【问题描述】:

我正在尝试在我的 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上配置key文件

<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 Security 项目的 Spring MVC

【问题讨论】:

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


    【解决方案1】:

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

    学习:始终先阅读日志
    编辑:任何人都可以使用它作为设置 SSL 的指南

    【讨论】:

      猜你喜欢
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 2022-06-18
      • 2022-05-25
      • 1970-01-01
      • 2014-06-27
      • 2012-02-06
      相关资源
      最近更新 更多