Tomcat10 简单地enable Https

编程入门 行业动态 更新时间:2024-10-28 14:34:45

Tomcat10 <a href=https://www.elefans.com/category/jswz/34/1770983.html style=简单地enable Https"/>

Tomcat10 简单地enable Https

通常来讲, 建站后要启用https 有下面3个步骤

1.购买域名
2.绑定域名和 服务器的外部IP地址
3.为这域名购买SSL 证书 (还有其密码)
4.在Tomcat上启用https 和安装这个证书

但是其实没有域名也可以在tomcat 中enable https的, 至于为什么, 当然是为了实现传输中的数据被加密了。

步骤:
首先是自己生成1个ssl证书, 当然这个证书是不被浏览器信任的, 但是这个是实现https的前提条件

keytool -genkey -alias tomcat -keyalg RSA -keystore keystore.jks -validity 36

这个命令会让你输入你想要的密码
还会问你若干关于证书的问题, 随便填就是

然后打开tomcat的server.xml

找到下面的注释, 并反注释它, 填入生成key的路径和密码

   <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2This connector uses the NIO implementation. The defaultSSLImplementation will depend on the presence of the APR/nativelibrary and the useOpenSSL attribute of the AprLifecycleListener.Either JSSE or OpenSSL style configuration may be used regardless ofthe SSLImplementation selected. JSSE style configuration is used below.--><Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"maxThreads="150" SSLEnabled="true"maxParameterCount="1000"><UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /><SSLHostConfig><Certificate certificateKeystoreFile="/home/gateman/keys/ssl/keystore.jks"certificateKeystorePassword="xxxxxx"type="RSA" /></SSLHostConfig></Connector>

重启tomcat服务器

就是用8443 访问tomcat了

更多推荐

Tomcat10 简单地enable Https

本文发布于:2023-11-16 15:35:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626464.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简单   Https   enable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!