实战Tomcat配置SSL,使用openssl制作证书
制作证书以及Tomcat配置
- 搭建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协议中的三次握手和四次挥手(图解)。
实战Tomcat配置SSL,使用openssl制作证书的更多相关文章
- 华为云服务器为Tomcat配置SSL
近期由于开发小程序需要在云服务器上配置https访问协议,也遇到了一点小问题,把配置过程记录一下:SSL 证书申请下来之后会有 .jks .crt .pfx .pem为后缀的文件(如何申请SSL证书这 ...
- TOMCAT配置SSL认证为HTTPS协议服务
1 . 问题概述 很多安全性要求较高的系统,都会使用安全套接字层(SSL)进行信息交换, Sun为了解决在Internet上的实现安全信息传输的解决方案.它实现了SSL和TSL(传输层安全)协议 ...
- 单点登录 SSO, 自动登录 , java 加密,ssl原理, Tomcat配置SSL
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 单点登录的英文简称为SSO(single sign on),单点登录功能使得用户只要登录 ...
- 轻松把玩HttpClient之配置ssl,采用绕过证书验证实现https
上篇文章说道httpclient不能直接访问https的资源,这次就来模拟一下环境,然后配置https测试一下.在前面的文章中,分享了一篇自己生成并在tomcat中配置ssl的文章<Tomcat ...
- Tomcat配置SSL
Tomcat配置SSL 查询网上资料配置如下: <Connector port="8443" protocol="HTTP/1.1" maxThreads ...
- Tomcat配置SSL证书(PFX证书)
公司项目,应该是阿里云服务器 在windows2008 R2搭建的 Tomcat部署SSL证书,本文以PFX证书为例. 配置好之后开始 一.什么是SSL(证书)? SSL证书服务(Alibaba Cl ...
- Mac下tomcat配置ssl
最近在搞单点登录CAS,第一步就是需要给tomcat配置证书.但是,第一次配置就遇到了个问题排插了一下午.下面来存一份文档,以备以后遇到. 一.首先准备好环境 java环境:配置好环境变量,找到jdk ...
- Springboot 配置 ssl 实现HTTPS 请求 & Tomcat配置SSL支持https请求
SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议.TLS与 ...
- Tomcat配置SSL连接
1.服务器端单项认证 在Tomcat的server.xml文件中,已经提供了现成的配置SSL连接器的代码,只要把<Connector>元素的注释去掉即可: <!— Define a ...
随机推荐
- 导航栏项目滑过时子菜单显示/隐藏jquery代码
;(function(window){ $('.menuitem').hover(function(){ $('>a',this).css('background-color ...
- Java Me-List控件的用法案例
/** * Java Me-List控件的用法案例 */package com.xushouwei.cn; import java.io.IOException;import javax.microe ...
- TortoiseSVN使用简介
TortoiseSVN使用简介 2009-04-24 来源: dev.idv.tw 1.安装及下载client 端 2.什么是SVN(Subversion)? 3.为甚么要用SVN? 4.怎么样在Wi ...
- Eclipse格式化代码换行、删除空行
Java代码 Window-preference-Java-Code Style-Formatter|Edit...-Line Wrapping|Maximum line width: 修改一行最大长 ...
- Bootstrap入门(三十)JS插件7:警告框
Bootstrap入门(三十)JS插件7:警告框 通过这个插件可以为警告信息添加点击以及消失的功能. 当使用一个.close按钮,它必须是第一个子元素.alert-dismissible,并没有文字内 ...
- windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help
windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help 在windows8操作系统上安装 ...
- [html5] 学习笔记-Canvas应用
通过使用HTML5游戏开发的引擎CreatJS,创建HTML5 Canvas上的更好交互. 1.认识CreateJS CreateJS是一个外部库,用它可以比Canvas更方便的绘制图形. 官网:ht ...
- .net 基础服务开源战略规划备忘录
公司现状 1. 技术人员水平限制: 基础研发人员技术细节,性能处理能力不足,技术视野不够开阔;甚至一些高可用,高性能方案的概念都未听闻,更别提发展方向和思路了,令人痛心. 2. 技术反馈渠道限制: 公 ...
- Vue.js 系列教程 3:Vue-cli,生命周期钩子
原文:intro-to-vue-3-vue-cli-lifecycle-hooks 译者:nzbin 这是 JavaScript 框架 Vue.js 五篇教程的第三部分.在这一部分,我们将学习 Vue ...
- 无限二等分[0,1]这个区间之后还剩下啥?what's left after dividing an unit interval [0,1] infinitely many times?
Dividing an unit interval \([0,1]\) into two equal subintervals by the midpoint \(\dfrac {0+1} {2}=\ ...