Tomcat启用HTTPS配置
2017-12-13 17:49
405 查看
获取证书
可使用jdk自带的keytool开生成证书,此种方式与向第三方权威机构购买的证书的区别为,第一次请求时需要选择信任站点并继续访问,在浏览器的地址框里会显示不安全的红色提醒。使用
keytool -genkey -alias tomcat -validity 3650 -keyalg RSA -keystore D://.keystore即可在D盘生成
.keystore文件,如下所示
PS C:\Users\YiYing\Desktop> keytool -genkey -alias tomcat -keyalg RSA -keystore D://.keystore 输入密钥库口令: 再次输入新口令: 您的名字与姓氏是什么? [Unknown]: YI 您的组织单位名称是什么? [Unknown]: CSS 您的组织名称是什么? [Unknown]: CSS 您所在的城市或区域名称是什么? [Unknown]: BJ 您所在的省/市/自治区名称是什么? [Unknown]: BJ 该单位的双字母国家/地区代码是什么? [Unknown]: CHINA CN=YI, OU=CSS, O=CSS, L=BJ, ST=BJ, C=CHINA是否正确? [否]: Y 输入 <tomcat> 的密钥口令 (如果和密钥库口令相同, 按回车): PS C:\Users\YiYing\Desktop>
说明:
- -alias为别名
- -validity 3650有效期为10年
- -keystore为生成的文件路径
Option Defaults Below are the defaults for various option values. -alias "mykey" -keyalg "DSA" (when using -genkeypair) "DES" (when using -genseckey) -keysize 1024 (when using -genkeypair) 56 (when using -genseckey and -keyalg is "DES") 168 (when using -genseckey and -keyalg is "DESede") -validity 90 -keystore the file named .keystore in the user's home directory -storetype the value of the "keystore.type" property in the security properties file, which is returned by the static getDefaultType method in java.security.KeyStore -file stdin if reading, stdout if writing -protected false
文档地址:
https://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html
Tomcat配置
需要修改tomcat的server.xml文件,如下所示:<!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <Connector SSLEnabled="true" clientAuth="false" keystoreFile="d://.keystore" keystorePass="111111" maxThreads="150" port="8443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS"/>
本来这一段是注释掉的,去掉注释并增加
keystoreFile和
keystorePass参数即可。
最后,启动服务器,使用
https://localhost:8443/即可访问服务器。
文档地址:
1. Tomcat7:https://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html
2. Tomcat8:https://tomcat.apache.org/tomcat-8.0-doc/ssl-howto.html
相关文章推荐
- Tomcat启用HTTPS协议配置过程
- tomcat启用https协议配置过程(有案例)
- Nginx + Tomcat + HTTPS 配置原来不需要在 Tomcat 上启用 SSL 支持
- Nginx + Tomcat + HTTPS 配置不需要在 Tomcat 上启用 SSL 支持
- Tomcat启用HTTPS协议配置过程
- Tomcat启用HTTPS协议配置过程
- 学习SSO-1 Tomcat启用ssl(含有配置https时的异常解决)
- Tomcat启用HTTPS(生成证书、配置Tomcatserver)
- 【转】Tomcat启用HTTPS协议配置过程
- 配置Tomcat启用Https安全协议的访问
- 【转】Tomcat启用HTTPS协议配置过程
- Tomcat启用HTTPS协议配置过程
- tomcat开发环境配置启用https
- Tomcat启用HTTPS协议配置过程
- HTTPS协议在Tomcat中启用是如何配置的
- Nginx + Tomcat + HTTPS 配置原来不需要在 Tomcat 上启用 SSL 支持
- Nginx + Tomcat + HTTPS 配置不需要在 Tomcat 上启用 SSL 支持
- Nginx + Tomcat + HTTPS 配置不需要在 Tomcat 上启用 SSL 支持 3ff8
- tomcat启用https配置
- Tomcat启用HTTPS(生成证书、配置Tomcat服务器)