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了

相关推荐
fei_sun11 分钟前
【复习】计网每日一题1124---UDP首部检验和计算、检验和特殊含义
网络·网络协议·udp
2***574226 分钟前
前端WebSocket案例
网络·websocket·网络协议
木易 士心1 小时前
WebSocket 与 MQTT 在即时通讯中的深度对比与架构选型指南
websocket·网络协议·架构
国服第二切图仔17 小时前
Electron for 鸿蒙PC实战案例Gitcode口袋工具之HTTP请求封装的技术实现与设计解析
http·electron·gitcode
s090713617 小时前
ZYNQ DMA to UDP 数据传输系统设计文档
网络协议·fpga开发·udp
hazy1k20 小时前
ESP32基础-Socket通信 (TCP/UDP)
c语言·单片机·嵌入式硬件·网络协议·tcp/ip·udp·esp32
赖small强20 小时前
【Linux 网络基础】WebSockets 技术指南
linux·网络·https·websockets·ping/pong
xinxinhenmeihao20 小时前
爬虫为什么要用动态ip?动态IP在爬虫中起到哪些作用?
爬虫·网络协议·tcp/ip
特种加菲猫1 天前
用户数据报协议(UDP)详解
网络·网络协议·udp
cccyi71 天前
HTTP 协议详解:从基础到核心特性
网络协议·http·应用层