詳解如何給Tomcat配置Https/ssl證書
如果需要給Tomcat開啟Https,首先我們需要一個(gè)證書,下面演示如何創(chuàng)建。
創(chuàng)建證書
keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "localhost-rsa.jks"
后面的信息隨便輸入,我這里輸入的是:
Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: pich What is the name of your organizational unit? [Unknown]: pich What is the name of your organization? [Unknown]: tomcat What is the name of your City or Locality? [Unknown]: beijing What is the name of your State or Province? [Unknown]: beijing What is the two-letter country code for this unit? [Unknown]: cn Is CN=pich, OU=pich, O=tomcat, L=beijing, ST=beijing, C=cn correct? [no]: y Enter key password for <tomcat> (RETURN if same as keystore password): Re-enter new password:
這樣就會(huì)在當(dāng)前目錄創(chuàng)建一個(gè)localhost-rsa.jks文件。密碼是123456,別名是tomcat。
給Tomcat配置證書
首先將上面生成的localhost-rsa.jks文件拷貝到Tomcat的conf目錄,然后打開該目錄下面的server.xml文件,找到如下代碼,原來是注釋了,現(xiàn)在需要打開注釋更改為如下內(nèi)容:
然后重新啟動(dòng)Tomcat,訪問https://localhost:8443/
就可以看到如下頁面:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="conf/localhost-rsa.jks" keystorePass="123456" />
可以看到地址欄是顯示為不安全的。因?yàn)檫@個(gè)證書是我們自己制作的,瀏覽器默認(rèn)不信任他,當(dāng)然你可以手動(dòng)信任他。12306他們的證書差不多就是這樣制作的。
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
tomcat默認(rèn)最大連接數(shù)與調(diào)整的方法示例
本文主要介紹了tomcat默認(rèn)最大連接數(shù)與調(diào)整的方法示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05
詳解tomcat設(shè)置默認(rèn)路徑致使項(xiàng)目url沖突解決方法
這篇文章主要介紹了詳解tomcat設(shè)置默認(rèn)路徑致使項(xiàng)目url沖突解決方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01
IDEA中Tomcat配置問題以及運(yùn)行報(bào)錯(cuò)的解決方案
這篇文章主要介紹了IDEA中Tomcat配置問題以及運(yùn)行報(bào)錯(cuò)的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
解決Tomcat啟動(dòng)失敗:嚴(yán)重?[main]?org.apache.catalina.util.LifecycleB
這篇文章主要介紹了解決Tomcat啟動(dòng)失敗:嚴(yán)重?[main]org.apache.catalina.util.LifecycleBase.handleSubClassException?初始化組件失敗問題的方法,希望可以幫助到你2023-03-03
詳解將Web項(xiàng)目War包部署到Tomcat服務(wù)器基本步驟
本篇文章主要介紹了詳解將Web項(xiàng)目War包部署到Tomcat服務(wù)器基本步驟,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
tomcat下部署jenkins的實(shí)現(xiàn)方法
本文主要介紹了tomcat下部署jenkins的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05

