1.生成密钥:
a.)首先生成一个pica.keystore(keystore密钥库)
备注:生产密钥库的路径最好在server服务器下。(如:jetty路径为${jetty.home}/etc/)
keytool -genkey -alias pica -keyalg RSA -dname "cn=localhost,ou=pica,o=wingware,l=china,st=beijing,c=cn" -keypass 123456 -storepass 123456 -keystore pica.keystore -validity 3600
此时会得到pica.keystore文件,[-keypass]是密钥的密码,[-storepass]是密钥库的密码,cn是域名,必须与cas服务器的域名相同(本地测试用localhost).
b.)从密钥库(pica.keystore)中导出证书pica.cer
keytool -export -trustcacerts -alias pica -file pica.cer -keystore pica.keystore -storepass 123456
c.)将证书(pica.cer)导入JDK的cacerts
keytool -import -trustcacerts -alias pica -file pica.cer -keystore “%JAVA_HOME%/jre/lib/security/cacerts” -storepass changeit
java中cacerts证书库默认密码为changeit
可以写一个批处理文件来执行上述命令。
2.配置jetty的ssl
jetty的配置修改/etc/ jetty-ssl.xml文件。
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- if NIO is not available, use org.eclipse.jetty.server.ssl.SslSocketConnector -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Set name="Port">8443</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="AcceptQueueSize">100</Set>
<Set name="Keystore"><SystemProperty name="jetty.home" default="." />/etc/pica.keystore</Set>
<Set name="Password">123456</Set>
<Set name="KeyPassword">123456</Set>
<Set name="truststore"><SystemProperty name="jetty.home" default="." />/etc/pica.keystore</Set>
<Set name="trustPassword">123456</Set>
</New>
</Arg>
</Call>
</Configure>
备注:
<Set name="truststore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
<Set name="trustPassword">123456 </Set>
可以不设置,默认会取${JAVA_HOME}/lib/secutity/cacerts这个文件夹
3.启动jetty
java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml
4.配置tomcat的ssl
连接器添加到server.xml文件中。
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="D:\Tomcat 6.0\bin\server.keystore"
keystorePass="123456" />
备注:keystoreFile为密钥库路径,keystorePass为密钥库的密码.
如果你希望客户端没有提供证书的时候SSL链接也能成功,也可以把clientAuth设置成want。
启动tomcat,访问 https://localhost:8443/,弹出一个安全警告的页面就OK了。
本地java访问https报错。
1.首先把lib\dynamic.12306.cn.crt证书导入到jdk的密钥库中
keytool -import -alias dukecert -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -file icq.net.crt -storepass changeit
-keystore密钥库路径
-storepass密钥库密码
输入keystore密码:changeit
分享到:
相关推荐
解决jetty8、jdk1.6环境下的ssl问题,示服务器的瞬时 Diffie-Hellman 公共密钥过弱,可以通过设置如下参数解决
这个wiki提供jetty的入门教程、基础配置、功能特性、优化、安全、JavaEE、监控、常见问题、故障排除帮助等等。它包含教程、使用手册、视频、特征描述、参考资料以及常见问题。 Jetty文档 ---------------- 入门...
配置SSL vi. 64.6. 配置Tomcat vii. 64.7. 启用Tomcat的多连接器(Multiple Connectors) viii. 64.8. 在前端代理服务器后使用Tomcat ix. 64.9. 使用Jetty替代Tomcat x. 64.10. 配置Jetty xi. 64.11. 使用Undertow...
为什么不只是在示例中使用 Jetty 配置? 或者部署到Tomcat什么的? Solr 使用 Jetty 进行了最彻底的测试。 具体来说,Jetty 与 Solr 捆绑在“example”目录中。 在 OpenSource Connections,我们经常需要帮助客户...
其他安全性插件正在用Tomcat,Jetty或其他繁琐的基于XML的JEE疯狂替代Elasticsearch的高性能,基于Netty的嵌入式REST API。 该插件只是一个轻量级的纯Java过滤层。 甚至SSL层也作为额外的Netty传输处理程序提
建议使用 Apache Maven 和 Tomcat 7 来运行此 Java 应用程序(而不是 Jetty,正如 Google 在其快速入门中推荐的那样)。 这部分是因为应用程序的 HTTPS/SSL 要求。 要部署,请确保从与 pom.xml 文件相同的
* Servlet adapter provided to let you deploy any Restlet application in Servlet compliant containers like Tomcat, when the usage of standalone HTTP connectors is not possible. * Implementation of ...
支持命名空间、二进制数据、SSL、ACK等功能。 环境搭建 开发工具: MySql:数据库 jetty:开发服务器 Tomcat:应用服务器 SVN|Git:版本管理 Nginx:反向代理服务器 Varnish:HTTP加速器 IntelliJ IDEA:开发IDE ...
Preparing a keystore for use with SSL 162 Certificate Authority portlet 164 Protecting passwords 164 HTTPS connectors 164 Tomcat HTTPS connectors 165 Jetty HTTPS connectors 166 JAAS login ...
51.3. Configuring Management-specific SSL 51.4. Customizing the Management Server Address 51.5. Disabling HTTP Endpoints 52. Monitoring and Management over JMX 52.1. Customizing MBean Names 52.2. ...