实战Tomcat配置SSL,使用openssl制作证书
2015-06-26 16:17
627 查看
制作证书以及Tomcat配置
搭建openssl环境,下载openssl并设置环境变量方便命令行的使用;
修改openssl配置文件,设置dir目录,如设置dir=e:/temp/openssl_ca,然后根据配置文件分别建立子目录:certs、crl、newcerts、private分别用来存放签发的证书、吊销的证书、证书申请、私钥;
根据配置文件,需要建立索引文件、序列号文件、随机数文件:
构建根证书密钥
密码是:oseye
构建根证书申请
签发根证书
构建服务器密钥
密码是:oseyemobile
构建服务器证书申请
签发服务器证书
此处为了安全可言采用sha512来签名,更多签名算法参见这里。
转换成java可用的格式
Export密码:oseyep12
使用keytool查看
修改tomcat的配置文件server.xml
通过./catalina.sh configtest来检测配置结果。
站点http自动到https的配置
在web.xml中
Tomcat在debian中的一点点PS
安装命令:
tomcat7配置文件:/etc/tomcat7/
tomcat7日志文件:/var/log/tomcat7
tomcat7 web默认webapps:/var/lib/tomcat7/webapps
修改使用sun jdk,需要在/etc/default/tomcat7添加修改变量:JAVA_HOME=/usr/oseye/lib/jvm/jdk1.7.0_67
TCP的三次握手以及状态的补充
可参考TCP的状态 (SYN, FIN, ACK, PSH, RST, URG)和TCP协议中的三次握手和四次挥手(图解)。
搭建openssl环境,下载openssl并设置环境变量方便命令行的使用;
修改openssl配置文件,设置dir目录,如设置dir=e:/temp/openssl_ca,然后根据配置文件分别建立子目录:certs、crl、newcerts、private分别用来存放签发的证书、吊销的证书、证书申请、私钥;
cd /d e:\temp\openssl_ca mkdir certs mkdir crl mkdir newcerts mkdir private
根据配置文件,需要建立索引文件、序列号文件、随机数文件:
cd /d e:\temp\openssl_ca echo 0 > index.txt echo 01 > serial openssl rand -out private/.rand 1000
构建根证书密钥
openssl genrsa -des3 -out private/ca.key.pem 2048
密码是:oseye
构建根证书申请
openssl req -new -key private/ca.key.pem -out newcerts/ca.csr -subj "/C=CN/ST=GD/L=SZ/O=oseye/OU=oseye/CN=*.oseye.net"
签发根证书
openssl x509 -req -days 100000 -sha1 -signkey private/ca.key.pem -in newcerts/ca.csr -out certs/ca.cer
构建服务器密钥
openssl genrsa -des3 -out private/mobile.key.pem 2048
密码是:oseyemobile
构建服务器证书申请
openssl req -new -key private/mobile.key.pem -out newcerts/mobile.csr -subj "/C=CN/ST=GD/L=SZ/O=oseye/OU=oseye/CN=mobile.oseye.net"
签发服务器证书
openssl x509 -req -days 100000 -sha1 -CA certs/ca.cer -CAkey private/ca.key.pem -CAserial ca.srl -CAcreateserial -in newcerts/mobile.csr -out certs/mobile.cer
此处为了安全可言采用sha512来签名,更多签名算法参见这里。
openssl x509 -req -days 100000 -sha512 -CA certs/ca.cer -CAkey private/ca.key.pem -CAserial ca.srl -CAcreateserial -in newcerts/mobile.csr -out certs/mobile.cer
转换成java可用的格式
openssl pkcs12 -export -clcerts -inkey private/mobile.key.pem -in certs/mobile.cer -out certs/mobile.p12
Export密码:oseyep12
使用keytool查看
keytool -list -keystore certs/mobile.p12 -storetype pkcs12 -v -storepass oseyep12
修改tomcat的配置文件server.xml
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="/var/oseye2.0/certs/mobile.p12" keystorePass="oseyep12" keystoreType="PKCS12" />
通过./catalina.sh configtest来检测配置结果。
站点http自动到https的配置
在web.xml中
<security-constraint> <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>
Tomcat在debian中的一点点PS
安装命令:
apt-get install tomcat7
tomcat7配置文件:/etc/tomcat7/
tomcat7日志文件:/var/log/tomcat7
tomcat7 web默认webapps:/var/lib/tomcat7/webapps
修改使用sun jdk,需要在/etc/default/tomcat7添加修改变量:JAVA_HOME=/usr/oseye/lib/jvm/jdk1.7.0_67
TCP的三次握手以及状态的补充
可参考TCP的状态 (SYN, FIN, ACK, PSH, RST, URG)和TCP协议中的三次握手和四次挥手(图解)。
相关文章推荐
- idea_IDEA跑Tomcat异常
- tomcat均衡负载
- 基于Tomcat7、Java、WebSocket的服务器推送聊天室项目
- tomcat 优化策略
- aws云平台的搭建相关资料和web站点tomcat搭建与mysql搭建实例
- #JSP#Tomcat下使用JSP调用JavaBean显示ClassNotFoundException
- 一个tomcat部署两个项目引发的血案:Web app root system property already set to different value: 'webapp.root'
- linux下tomcat开机启动简单配置
- win7下安装配置tomcat,java运行环境
- Eclipse项目配置以及Tomcat访问权限设置
- mac下tomcat的安装与配置
- Solr5.2.1搜索服务部署——tomcat安装
- tomcat set bat file
- 8.Tomcat 如何启动停止?
- Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法
- Tomcat优化及压力测试实例 .
- 如何修改和查看tomcat内存大小
- mac上jdk1.8换1.7 eclipse tomcat
- Tomcat:bio nio 的设计
- tomcat性能优化参数