Loading

Tomcat配置HTTPS访问

获取证书

进入jdk安装目录或者配置了jdk环境变量

keytool -genkey -alias tomcat -keyalg RSA -keystore /mnt/apache-tomcat-7.0.56/conf/.keystore

/mnt/apache-tomcat-7.0.56/conf/.keystore 证书存放路径

输入密钥库口令:Jac1@#kie

  再次输入新口令: Jac1@#kie

  您的名字与姓氏是什么?

     [Unknown]:  jackie cheng

  您的组织单位名称是什么?

   [Unknown]:  ideal

  您的组织名称是什么?

     [Unknown]:  jc

  您所在的城市或区域名称是什么?

    [Unknown]:  shanghai

  您所在的省/市/自治区名称是什么?

    [Unknown]:  shanghai

  该单位的双字母国家/地区代码是什么?

    [Unknown]:  CN

  CN=jackie cheng, OU=ideal, O=jc, L=shanghai, ST=shanghai, C=CN是否正确?

    [否]:  y

  输入 <tomcat> 的密钥口令

        (如果和密钥库口令相同, 按回车):

名字与姓名输入域名(例如:localhost)

配置tomcat

修改tomcat\config\server.xml

    <!--<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
			   keystoreFile="/data/tomcat8.0.53/ssl/keystore"
			   keystorePass="123456"
			   />-->
  
	<Connector port="8443" protocol="HTTP/1.1" 
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
			   keystoreFile="/data/tomcat8.0.53/ssl/.keystore" 
			   keystorePass="123456" 
			   />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

keystoreFile="/data/tomcat8.0.53/ssl/.keystore" 证书存放位置
keystorePass="123456" 证书密码

配置完成后,重启TOMCAT后即可以使用SSL。IE地址栏中可以直接输入地址 “https:ip:8443//”。

posted @ 2020-12-11 20:55  猫鱼故巷  阅读(591)  评论(0编辑  收藏  举报