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了

相关推荐
q567315235 分钟前
自动化拨号爬虫体系:虚拟机集群部署与增量管理
运维·爬虫·网络协议·自动化
刘 大 望1 小时前
传输层:UDP/TCP协议
java·网络·网络协议·tcp/ip·udp·信息与通信
吾日三省吾码2 小时前
用 Python UTCP 直调 HTTP、CLI、MCP……
开发语言·python·http
彬彬醤4 小时前
TikTok矩阵有哪些运营支撑方案?
大数据·网络·网络协议·tcp/ip·矩阵·udp·产品运营
楠枬4 小时前
DNS 域名解析
服务器·网络·网络协议
天上的光7 小时前
计算机网络——协议
网络·网络协议
百渡ovO7 小时前
HTTP快速入门
网络·网络协议·http
2501_915909067 小时前
苹果上架App软件全流程指南:iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传与审核技巧详解
android·ios·小程序·https·uni-app·iphone·webview
2501_915918418 小时前
App 苹果 上架全流程解析 iOS 应用发布步骤、App Store 上架流程
android·ios·小程序·https·uni-app·iphone·webview
2501_916007478 小时前
苹果上架全流程详解,iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传与审核要点完整指南
android·ios·小程序·https·uni-app·iphone·webview