Tomcat Https配置

来源:互联网 发布:重庆seo网站诊断 编辑:程序博客网 时间:2024/04/30 23:26

1、生成keystore
keytool -genkey -alias testssl.nb.com -keyalg RSA -keystore /data/zs/niubiyuming.keystore
2、导出证书 (可以直接用第三方证书)
keytool -export -file /data/zs/niubiyuming.crt -alias testssl.nb.com -keystore /data/zs/niubiyuming.keystore

3、把keystore转换为pkcs12格式
keytool -importkeystore -srckeystore /data/zs/niubiyuming.keystore -destkeystore /data/zs/niubiyuming.p12 -deststoretype PKCS12
4、使用openssl工具导出私钥
openssl pkcs12 -in /data/zs/niubiyuming.p12 -out /data/zs/niubiyuming.pem -nodes


5、Tomcat配置


安装:SSL模块
yum install mod_ssl -y 安装:SSL模块


    <Connector port="80" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="443" />


<Connector port="443" maxHttpHeaderSize="8192"
                 maxThreads="150"
                 enableLookups="false" disableUploadTimeout="true"
                 acceptCount="100" scheme="https" secure="true"
                 SSLEnabled="true"
                 SSLCertificateFile="/data/zs/niubiyuming.crt"
                 SSLCertificateKeyFile="/data/zs/niubiyuming.pem" />


 
6、访问测试
https://testssl.nb.com/
http://testssl.nb.com/
 


7、证书相关信息
Country Name (2 letter code) [XX]:CN  #国家地区
State or Province Name (full name) []:zhejiang  #城市
Locality Name (eg, city) [Default City]:hangzhou  #当地名称
Organization Name (eg, company) [Default Company Ltd]: niubiyuming #组织名称
Organizational Unit Name (eg, section) []:IT  #组织部门名称
Common Name (eg, your name or your server's hostname) []:testssl.nb.com #通用名称(例如,您的姓名或您的服务器的主机名),随便写
Email Address []:1111111@qq.com  #邮箱
Please enter the following 'extra' attributes 
to be sent with your certificate request #添加一个“额外”的属性,让客户端发送CA证书,请求文件时,要输入的密 
A challenge password []: #直接加车 
An optional company name []:#直接加车
Using configuration from /etc/pki/tls/openssl.cnf #CA服务器的配置文件。上面修改的内容会添加到这个配置文件中

Enter pass phrase for /etc/pki/CA/private/./cakey.pem: 123456 #输入刚才保护CA密钥的密码




0 0
原创粉丝点击