首页 > 代码库 > Tomcat 启用 Https
Tomcat 启用 Https
生成 key
$JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
# $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: YourName What is the name of your organizational unit? [Unknown]: YourOrgUnit What is the name of your organization? [Unknown]: YourOrg What is the name of your City or Locality? [Unknown]: YourCity What is the name of your State or Province? [Unknown]: YourState What is the two-letter country code for this unit? [Unknown]: CN Is CN=YourName, OU=YourOrgUnit, O=YourOrg, L=YourCity, ST=YourState, C=CN correct? [no]: yes Enter key password for <tomcat> (RETURN if same as keystore password): Re-enter new password:
特别说明:上边输入的“ 的主密码”,与 keystore 密码一定要相同,否则TOMCAT起不来
然后将生成的 .keystore 文件 copy 到 $CATALINA_BASE/conf 目录
编辑 $CATALINA_BASE/conf/server.xml
打开下面的配置
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="./conf/.keystore" keystorePass="password" />
- keystoreFile: 就是刚才创建的证书文件,这里使用的是相对目录,也就是tomcat根目录.
- keystorePass: 是你创建证书时输入的密码.
启动 Tomcat
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。