当前位置:网站首页>给网站添加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......试试吧。
边栏推荐
- Leetcode height checker
- C language elementary level (IX) enumeration
- [deeply understand tcapulusdb technology] tmonitor system upgrade
- . Net synchronization mechanism and application examples
- [deeply understand tcapulusdb technology] tcapulusdb import data
- MySQL - built in functions
- Are you still using generator to generate crud code of XXX management system? Let's see what I wrote
- Collection reference type in JS
- MySQL - index
- Lamp architecture 6 -- MySQL master-slave replication and optimization method
猜你喜欢

还在用generator生成xxx管理系统的CRUD代码?来看看我是怎么写的
JS 中的集合引用类型

Deep understanding of convolution in convolution neural network

Map collection traversal, adding, replacing and deleting elements

Repair for a while, decisively reconstruct and take responsibility -- talk about CRM distributed cache optimization

MySQL - table join and join

Please, don't use pessimistic locks in high concurrency scenarios!

A blazor webassembly application that can automatically generate page components based on objects or types

SCCM creates a client collection based on the installed app and periodically pushes application updates

应用配置管理,基础原理分析
随机推荐
【深入理解TcaplusDB技术】TcaplusDB业务数据备份
Explanation of common mesh generation methods in workbench
Installation and application of MySQL 8.0 under Linux
Cvpr2022 | the action sequence verification task was first proposed by X xiaohongshu of Shanghai University of science and technology, which can be applied to multiple scenarios such as scoring of spo
Prepare for the golden three silver four, are you ready? Summary of software test interview questions
如何使用搜索引擎?
MySQL - user management
5. array
Kubernetes快速實戰與核心原理剖析
618 Nuggets digital collection? Burberry and other luxury brands fight against metauniverse
Kubernetes' fast practice and core principle analysis
Questions and answers No. 43: application performance probe monitoring principle PHP probe
Unbounded territory won the title of innovative brand of digital culture industry in 2022
Qinglong panel, JD timed task library, script library
Write efficient defect reports
How to guarantee the test coverage
Modification method of EKF extended Kalman filter for omnidirectional ground
Memcached (high performance memory object cache)
Iterm2 file transfer with remote server
咨询:微证券是什么证券公司,开户安全吗?