linux tomcat 配置https
一.认识https
网上已经有很多介绍https的原理,这里我只概述一下。
相对于http的明文传输,https是基于ssl的加密传输协议。
具体参见:http://jingyan.baidu.com/article/a948d6515d3e850a2dcd2ee6.html
二.获取证书
获取证书的途径大概有两种,其一为使用jdk自带的keytool工具制作,其二为在网上购买或者申请免费的证书。
网上申请免费证书主要之对于个人使用,需要的自行百度。
以下介绍使用jdk自带的keytool工具生成证书:
1.进入jdk的bin目录下 cd /yourpath/jdkxx/bin
2.输入命令keytool -genkey -v -alias tomcat -keyalg RSA -keystore /usr/local/tomcat8888/conf/tomcat.keystore -validity 365(其中-alias tomcat 指定昵称,-keyalg RSA指定加密类型,-keystore /..指定证书存储路径及名称,-validity 365指定证书过期时间,天为单位。更多keytool参数请使用命令 keytool -help查看)
之后提示Enter keystore password: (设置证书密码,请输入至少6位字符)
Re-enter new password:(新密码确认)
What is your first and last name?
[Unknown]:(必填,且为tomcat主键的访问域名或者ip)
What is the name of your organizational unit?
[Unknown]:(组织单位名称,随便填。。)
What is the name of your organization?
[Unknown]:(组织名称,自行决定)
......以下按提示输入即可,确认信息时检查无误输入y确认后输入初始设定密码即可
以上证书生成完毕,可到之地路径查看证书。
三.tomcat配置https
进入tomcat的conf路径,打开server.xml文件 vim server.xml
找到
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
注释内容,复制或者打开注释修改为
<Connector port="8443" protocol="HTTP/1.1"
SSLEnabled="true" maxThreads="150" scheme="https"
secure="true" clientAuth="false" sslProtocol="TLS"
keystoreFile="/usr/local/tomcat8888/conf/tomcat.keystore" keystorePass="yourpassword" />
此时浏览器访问https://yourdomainname:8443端口时会出现证书不安全提示,如果访问http://yourdomainname:8080则不提示,依然为http访问,如果要实现任意端口访问均自动为https,则增加一下操作:
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>
实现强制https访问,则访问http://yourdomainname:port时也会自动跳转到https.
over!此处主要作为个人笔记,如能给他人带来益处则甚好。
- linux tomcat配置https的方法
- windows和linux下配置tomcat的https通信(ssl单向认证)
- Tomcat配置https环境(Windows+Linux)
- Tomcat配置https环境(Windows+Linux)
- Tomcat配置https环境(Windows+Linux)
- 阿里云 centos7 linux如何配置tomcat的https
- 针对linux tomcat服务器 配置https协议
- linux apache Tomcat配置SSL(https)步骤
- Tomcat配置https环境(Windows+Linux)
- linux 配置tomcat https访问
- linux tomcat 配置https(SSL)
- linux系统下用单向认证方式将Tomcat配置成https方式访问
- linux中tomcat中https配置
- Linux Tomcat Https 访问配置!
- window与Linux 配置 tomcat Https 访问
- Tomcat6 配置HTTPS SSL 发布Axis2 webservice(一)配置【windows中操作,linux中类似此操作】
- linux tomcat配置https
- linux下配置tomcat的https实例
- 配置Tomcat使用https协议(配置SSL协议)
- tomcat配置https自签名证书