cas 集成笔记一 tomcat配置ssl(https)

一、需要生成SSL证书,用到keytool工具

keytool -genkey -alias aliasName -dname "CN=cas.server.com,OU=xxx,O=xxx,L=beijing,ST=beijing,C=CN" -keyalg RSA -

keysize 1024 -keypass xxxxxx -storepass xxxxxx -keystore xxxxxx.keystore -validity 3600 

-alias:为证书别名

-dname:一次性生成证书,不加这个,需要命令后按照提示 一次写这些信息

 "CN=名字与姓氏,OU=组织单位名称,O=组织名称,L=城市或区域名称,ST=州或省份名称,C=单位的两字母国家代码"

-keyalg :编码方式

-keysize:密文长度

-keypass:指定别名条目的密码(私钥的密码)

扫描二维码关注公众号,回复: 766630 查看本文章

-storepass:指定密钥库的密码(获取keystore信息所需的密码)

-keystore:生成的秘钥库的路径和文件名字、

-validity:证书有效期

二。导出证书文件

keytool -export -alias aliasName -keystore xxxx.keystore -file xxxx.crt -storepass xxxx

导出证书供客户端用

三.将证书导入的JDK的证书信任库中

keytool -import -trustcacerts -alias xxxxx -file xxxxx.crt -keystore  "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit

注意:

changeit是 jdk证书库默认的密码

如果是windows主机,使用%JAVA_HOME%,如果是linux就使用$JAVA_HOME

四。修改conf/server.xml文件 使其支持 ssl(https)

打开注释

<Connector port="443" protocol="HTTP/1.1"
        connectionTimeout="5000" URIEncoding="UTF-8"
        scheme="https" secure="true" SSLEnabled="true"
        clientAuth="false" sslProtocol="TLS"
        keystoreFile="/opt/tomcat/ssl/server.keystore"
        keystorePass="xxxxx"/>

注意:

 keystoreFile="/opt/tomcat/ssl/server.keystore"
        keystorePass="xxxxx" 这两个是新加的 keystoreFile是证书库的路径,keystorePass是证书库的访问密码

参考资源:

http://blog.chinaunix.net/uid-17102734-id-2830223.html

http://www.111cn.net/sys/CentOS/67452.htm

猜你喜欢

转载自feiteyizu.iteye.com/blog/2242871