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了

相关推荐
Bingo_BIG1 小时前
UA 配置Https域名
https·ua
卓伊凡1 小时前
详细讲述优雅草蜻蜓I即时通讯私有化中xmpp服务中的tigase的角色与作用深度分析-卓伊凡|bigniu
网络协议
雨白2 小时前
HTTP协议详解(一):工作原理、请求方法与状态码
android·http
DemonAvenger2 小时前
Go语言实现高并发网络爬虫:技术实践与经验分享
网络协议·架构·go
望未来无悔6 小时前
HTTPS的概念和工作过程
网络协议·https
游戏开发爱好者87 小时前
Fiddler中文版使用指南 提升开发流程的一站式抓包与调试体验
android·ios·小程序·https·uni-app·iphone·webview
PineappleCoder7 小时前
为什么输入 URL 后会显示页面?HTTP 协议的 “幕后操作”
前端·http·面试
EndingCoder8 小时前
HTTP性能优化实战:解决高并发场景下的连接瓶颈与延迟问题
网络·网络协议·http·性能优化·高并发
IPIDEA全球IP代理9 小时前
IPIDEA:全球领先的企业级代理 IP 服务商
网络·网络协议·tcp/ip
十年一梦实验室9 小时前
工业机器人控制系统 IP-PP-EXEC 流水线
网络·人工智能·网络协议·tcp/ip·机器人