配置 SSL 证书
一、Nginx
# 443 端口
server {
#SSL 访问端口号为 443
listen 443 ssl;
#填写绑定证书的域名
server_name domain;
#证书文件名称
ssl_certificate /etc/nginx/ssl/domain_bundle.crt;
#私钥文件名称
ssl_certificate_key /etc/nginx/ssl/domain.key;
# 设置 SSL 会话缓存。存储 SSL 会话参数,以便在同一客户端的后续连接中重用,从而减少 SSL 握手的开销
# shared:SSL:1m 表示创建一个名为 "SSL" 的共享内存区,大小为 1MB。这个内存区可以被所有工作进程(worker process)共享,用于存储 SSL 会话参数。
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1.2 TLSv1.3;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
charset utf-8;
default_type text/plain;
root /etc/nginx/html;
location / {
root html;
index index.html index.htm;
}
location /ctx {
proxy_pass http://localhost:8080/ctx;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
二、Tomcat
- 把
jks
证书复制到${TOMCAT_HOME}/conf/
下 - 修改
${TOMCAT_HOME}/conf/server.xml
<!-- https 访问端口, keystoreFile 指定 jks 文件的地址,keystorePass 指定 jks 的密码 -->
<Connector port="443" protocol="HTTP/1.1"
connectionTimeout="20000"
SSLEnabled="true"
scheme="https"
secure="true"
keystoreFile="D:/TOMCAT/apache-tomcat-9.0.68/conf/(20230713131002)tomcat.jks"
keystorePass="Abc_123"
clientAuth="false"
/>
<!--http 访问端口 , 将 http 端口的请求转发到 https 端口-->
<Connector port="9999" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
- 修改
${TOMCAT_HOME}/conf/web.xml
<!--在 web.xml 末尾加上-->
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
- 重启
Tomcat
三、WebLogic
四、troubleshooting
1、crt
转 jks
的方法
2、查看 jks 的别名
查看 jks 的别名。在 cmd 中执行下面的命令(需要在 keystore.js 所在文件下打开命令行)
keytool -v -list -keystore keystore.jks
acme.sh 签署证书
https://cloud.tencent.com/developer/article/2335528
安装
curl https://get.acme.sh | sh -s email=wangzhy@linux.do
配置 tencent api 访问密钥
API 密钥管理地址:https://console.cloud.tencent.com/cam/capi
配置环境变量
export Tencent_SecretId="AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export Tencent_SecretKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"