首页 > 解决方案 > 如何为 java servlet 应用程序设置 https

问题描述

我创建了一个 java servlet web 应用程序。它与“http”一起正常工作。现在我想设置到服务器的“https”安全连接。为此,我已在 tomcatserver/conf/server.xml 中正确配置了如下内容。

Connector port="8443" protocol="HTTP/1.1"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
           keystoreFile="conf\localhost.jks" keystorePass="xxxx"
           clientAuth="false" sslProtocol="TLS" />

然后我在 web.xml 文件上也配置了如下内容。

<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTTPSOnly</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

当我通过邮递员发送请求时,出现以下错误。 在此处输入图像描述

在这里,我还附上了请求标头。 在此处输入图像描述

我该如何解决这个问题?

标签: httptomcatservletshttps

解决方案


推荐阅读