大佬教程收集整理的这篇文章主要介绍了详解如何给Tomcat配置Https/ssl证书,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如果需要给tomcat开启https,首先我们需要一个证书,下面演示如何创建。
创建证书
keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "localhost-rsa.jks"
Enter keystore password: Re-enter new password: what is your first and last name? [UnkNown]: pich what is the name of your organizational unit? [UnkNown]: pich what is the name of your organization? [UnkNown]: tomcat what is the name of your City or Locality? [UnkNown]: beijing what is the name of your State or province? [UnkNown]: beijing what is the two-letter country code for this unit? [UnkNown]: cn Is CN=pich,OU=pich,O=tomcat,L=beijing,ST=beijing,C=cn correct? [no]: y Enter key password for <tomcat> (RETURN if same as keystore password): Re-enter new password:
这样就会在当前目录创建一个localhost-rsa.jks文件。密码是123456,别名是tomcat。
给tomcat配置证书
首先将上面生成的localhost-rsa.jks文件拷贝到tomcat的conf目录,然后打开该目录下面的server.xml文件,找到如下代码,原来是注释了,现在需要打开注释更改为如下内容:
然后重新启动tomcat,访问https://localhost:8443/
就可以看到如下页面:
<Connector port="8443" protocol="org.apache.coyote.http11.http11NioProtocol" SSLEnabled="true" maxThreads="150" scheR_943_11845@e="https" secure="true" clIEntAuth="false" sslProtocol="TLS" keystorefile="conf/localhost-rsa.jks" keystorePass="123456" />
可以看到地址栏是显示为不安全的。因为这个证书是我们自己制作的,浏览器默认不信任他,当然你可以手动信任他。12306他们的证书差不多就是这样制作的。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。
以上是大佬教程为你收集整理的详解如何给Tomcat配置Https/ssl证书全部内容,希望文章能够帮你解决详解如何给Tomcat配置Https/ssl证书所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。