我已经创建了一个 Java servlet。我需要使用双向 SSL 连接来托管它。我获得了两个 .cer 文件来实现这一点。我创建了一个 Java keystore 以与 Apache tomcat 一起使用来部署我的 servlet。我的 https 连接的 server.xml 为
<Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
disableUploadTimeout="true" enableLookups="false" maxThreads="25"
port="30580" keystoreFile="SSLConnect.jks" keystorePass="$Actual
password" protocol="org.apache.coyote.http11.Http11NioProtocol"
scheme="https" secure="true" sslProtocol="TLS" />
和
我还通过添加
在 servlet 中启用了 https<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
到 web.xml 文件。
尽管如此,任何人都可以使用我将服务部署到的 URL 连接到该服务。由于通过 https 启用了 SSL,您是否不需要证书来连接到 URL?我在这里做错了什么吗?
最佳答案
您需要设置clientAuth="true"
,而不是clientAuth="false"
。
关于ssl - 尽管使用 SSL,任何人都可以连接到我的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56652920/