目前免费SSL证书有很多家,对于个人建站挂个https就足够了。我的域名证书是在https://freessl.cn/ 申请的,免费使用,到期会提醒免费更换,申请完下载full_chain.pem,private.key2个文件,也可以在他们的网站或者https://myssl.com/上转换为jks格式或者p12格式
为Tomcat添加SSL证书:
找到tomcat conf目录下的server.xml文件,添加:
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="www.websoso.cn">
<SSLHostConfig hostName="www.websoso.cn" caCertificateFile="conf/websoso.jks">
<Certificate certificateKeystoreFile="conf/websoso.jks"
certificateKeystorePassword="password" type="RSA" />
</SSLHostConfig>
</Connector>
编辑conf目录下的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>
注意:本文归作者所有,未经作者允许,不得转载