当前位置:网站首页>给网站添加SSL安全证书
给网站添加SSL安全证书
2022-06-21 13:43:00 【sunonzj】
今天终于是给网站加了个证书,现在要通过https访问了。关于加证书的好处就不多说了,大大提升网站安全性,而且SEO排名也是有点用的。现在基本上都是https了,算是顺应潮流。
证书申请
我是用的腾讯云,搜索ssl可以直接申请一个一年免费的证书。
选择这个免费的
名称随便填一个,邮箱和域名填写好,私钥可以不填。然后就可以申请等待通过了,大概半天就能好,比域名备案快多了~
审核通过后就可以下载证书进行配置了
证书配置
将证书下载下来,解压后可以看到有四个文件夹,代表了四种环境下的证书,根据自己需求选择。我服务器用的是Tomcat,所以这里就讲下Tomcat的配置。
将Tomcat文件夹下的www.zjhuiwan.cn.jks文件上传到服务器Tomcat安装目录的conf文件夹下。
打开server.xml,进行如下修改。
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<!--证书配置 -->
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/root/apache-tomcat-8.0.53/conf/www.zjhuiwan.cn.jks"
keystorePass="****"
clientAuth="false" sslProtocol="TLS" />证书配置这一段是新加的,keystorePasss是证书里keystorePass.txt文件中的内容。keystoreFile是上传到服务器中的证书的绝对路径(之前用相对路径一直没用)。
然后还要修改上面port为80的这一段配置,redirectPort修改为新加的证书配置的443(http跳转到https),重启tomcat后便会生效。
注:
配置文件参数 | 说明 |
|---|---|
clientAuth | 如果设为true,表示Tomcat要求所有的SSL客户出示安全证书,对SSL客户进行身份验证 |
keystoreFile | 指定keystore文件的存放位置,可以指定绝对路径,也可以指定相对于<catalina_home> (Tomcat安装目录)环境变量的相对路径。如果此项没有设定,默认情况下,Tomcat将从当前操作系统用户的用户目录下读取名为 “.keystore”的文件。 |
keystorePass | 密钥库密码,指定keystore的密码。(如果申请证书时有填写私钥密码,密钥库密码即私钥密码) |
sslProtocol | 指定套接字(Socket)使用的加密/解密协议,默认值为TLS |
http自动跳转为https配置
配置web.xml文件,直接在最后加上以下配置:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<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>
<!--在这上面添加新配置-->
</web-app>好了,配置好了,重启Tomcat。打开浏览器输入https://www......试试吧。
边栏推荐
- C language -- program compilation and linking
- 基于STM32电压检测和电流检测
- 修修补补一时爽,果断重构有担当——聊聊CRM分布式缓存优化
- Artifacial Intelligent Project
- Web3.js connection to metamask wallet transfer
- Distributed transactions, simple in principle, are all pits in writing
- IMU selection, calibration error analysis, AHRS integrated navigation
- Open source FTP server FileZilla server
- Using slurm cluster computing node debugger in vscode
- [in depth understanding of tcapulusdb technology] tcapulusdb business data backup
猜你喜欢

【深入理解TcaplusDB技术】TcaplusDB构造数据

Memcached (high performance memory object cache)

使用seaborn绘制热图

MySQL - table join and join
![[deeply understand tcapulusdb technology] tmonitor system upgrade](/img/ec/bbfb7e2f19a94b69ec0a6092fd3032.png)
[deeply understand tcapulusdb technology] tmonitor system upgrade

MySQL - index

MySQL - built in functions

Swift return button

Reading notes on how to connect the Internet ADSL

The new plan for national treasures - the exclusive digital collection of the four museums is coming!
随机推荐
3D slicer saves segmentation results
Distributed transaction processing scheme big PK
Heat mapping using Seaborn
Eureka的TimedSupervisorTask类(自动调节间隔的周期性任务)
Redis学习(1)——概述和常用命令
8. structure
seaborn数据总体分布的可视化策略
Test the interface between app and wechat applet
如何使用搜索引擎?
Eureka's timedsupersortask class (periodic task with automatic interval adjustment)
C language -- program compilation and linking
咨询:微证券是什么证券公司,开户安全吗?
2. reference
C language elementary order (VI) function
Lamp architecture 5 - MySQL Cluster and master-slave structure
Artifacial Intelligent Project
微证券开户正规安全吗,怎么操作开户?
Redis学习(3)—— 持久化机制
Memcached (high performance memory object cache)
Detailed explanation and examples of common parameters of curl