Tomcat10 简单地enable Https

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

1.购买域名

2.绑定域名和 服务器的外部IP地址

3.为这域名购买SSL 证书 (还有其密码)

4.在Tomcat上启用https 和安装这个证书

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

步骤:

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

bash 复制代码
keytool -genkey -alias tomcat -keyalg RSA -keystore keystore.jks -validity 36

这个命令会让你输入你想要的密码

还会问你若干关于证书的问题, 随便填就是

然后打开tomcat的server.xml

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

bash 复制代码
   <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
         This connector uses the NIO implementation. The default
         SSLImplementation will depend on the presence of the APR/native
         library and the useOpenSSL attribute of the AprLifecycleListener.
         Either JSSE or OpenSSL style configuration may be used regardless of
         the 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了

相关推荐
隐擎fox7 小时前
高性能网络爬虫架构设计:基于 Python 的长连接复用与分布式会话池调度实践
分布式·python·网络协议·tcp/ip·高并发·网络爬虫、
IT摆渡者9 小时前
1panel 配置申请手动解析网站SSL证书
服务器·网络协议·ssl
易岳群9 小时前
物联网 MQTT 方案:服务端如何通过 MQTT 生命周期维护客户端设备状态
物联网·网络协议
2501_9378609413 小时前
网络核心|OSI七层、TCP/IP五层模型,封装和分用详解
网络·网络协议·tcp/ip
ControlRookie14 小时前
第23篇_源码加更 05|HTTP Server、连接实例和诊断数据
http·codesys·plc通信·开源源码
宵时待雨15 小时前
linux笔记归纳18:传输层协议TCP
linux·网络·笔记·网络协议·tcp/ip
captain37616 小时前
▲网络原理(1)-UDP
网络·网络协议·tcp/ip
开开心心就好17 小时前
清理此电脑网盘图标工具,开源免费好用
网络·网络协议·tcp/ip·智能手机·电脑·scala·erlang
企业数字化笔记18 小时前
AI写的网站一直自动跳转怎么办?301、302和HTTPS重定向排查
网络协议·http·https
IT摆渡者19 小时前
1panel 针对HTTP自动续签SSL网站证书
网络协议·ssl·openresty