網站首頁 編程語言 正文
公司網站鏈接要由原來的http超文本傳輸協議訪問改為https SSl加密傳輸協議訪問。
HTTP與HTTPS的區別:HTTP協議傳輸的數據都是未加密的,也就是明文的,因此使用HTTP協議傳輸隱私信息非常不安全,為了保證這些隱私數據能加密傳輸,于是網景公司設計了SSL(Secure Sockets Layer)協議用于對HTTP協議傳輸的數據進行加密,從而就誕生了HTTPS。簡單來說,HTTPS協議是由SSL+HTTP協議構建的可進行加密傳輸、身份認證的網絡協議,要比http協議安全。
我花了一塊錢(一年)在愛名網購買了一個Symantec Basic DV 證書。下載證書解壓之后是這個樣子的:
打開IIS文件夾:
包含證書的密碼和一個pfx格式的證書。我開始用pfx格式證書來配置一直沒成功,就選擇了把pfx格式轉換成jks格式的證書來配置,成功了。這里就講jks格式證書的配置。
一、使用java jdk將PFX格式證書轉換為JKS格式證書
先切換到IIS文件夾下,執行命令:
keytool -importkeystore -srckeystorewww.dongnaoedu.com_ssl.pfx?-destkeystoredomains.jks?-srcstoretype PKCS12 -deststoretype JKS
這里要輸入密碼,就是上面www.dongnaoedu.com_pfx_password.txt文本文件中的密碼,3個口令最好都輸入這個密碼??梢钥吹轿募A中生成了domains.jks證書
二、配置server.xml
先把domains.jks證書上傳到Tomcat的conf文件夾下:
切換到conf目錄下編輯server.xml
- cd /usr/tomcat/apache-tomcat-8.5.11/conf
- vim server.xml
找到:
<!-- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS"/> -->
去掉注釋,修改為:(443為https默認訪問端口)
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="conf/domains.jks" //證書地址 keystorePass="582629" //證書密鑰 clientAuth="false" sslProtocol="TLS" />
為了讓http訪問自動跳轉為https訪問,這里順便把這兩個標簽也改了,
找到:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
修改為:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
找到:
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="8443" />
修改為:
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />
保存退出。
三、配置web.xml
編輯web.xml
- vim web.xml
在該文件</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>
保存退出。所有配置完畢。重啟Tomcat即可。證書生效,并且http訪問會自動轉為https訪問。
原文鏈接:https://blog.csdn.net/Axela30W/article/details/77145887
相關推薦
- 2023-10-31 SpringBoot手動獲取實例
- 2022-03-31 用Python實現石頭剪刀布游戲_python
- 2022-08-14 Python數據處理之pd.Series()函數的基本使用_python
- 2022-08-15 gitlab代碼合并(merge request )取消 [默認刪除分支(Delete source
- 2023-03-03 PostgreSQL死鎖了怎么辦及處理方法_PostgreSQL
- 2022-06-02 Python中函數的創建與調用你了解嗎_python
- 2023-01-02 Python中字符串的常用方法總結_python
- 2022-02-22 用Go+Redis實現分布式鎖的示例代碼_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支