java - 本地主机 tomcat 中的安全连接无法正常工作

标签 java spring maven tomcat ssl

我正在使用 maven 开发 spring web 应用程序。我正在尝试使 localhost 成为安全连接。我正在使用 tomcat 服务器。我用了这个link用于创建我自己的 CA 并将其添加到 JVM。 这是我在 pom.xml 中添加的内容。

<plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <path>/security</path>
            <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true" maxThreads="200" scheme="https" secure="true" keystoreFile="/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64/jre/lib/security/cacerts.jks" keystorePass="security"
           clientAuth="false" sslProtocol="TLS" />

        </configuration>
</plugin>

我去了链接:https://localhost:8443 .但是该端口上没有运行任何应用程序。有人可以帮忙吗?

最佳答案

转到 sever.xml 并添加以下 xml

 <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" 
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 
clientAuth="false" sslProtocol="TLS" keystoreFile="{path}/mycer.cert" keystorePass="{password}"/>
     <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
  1. 首先你要创建一个CA证书
  2. 您可以使用 java key 工具创建证书
  3. 将该证书存储在您的服务器上。
  4. 在您的 tomcat server.xml 中添加连接器配置
  5. 您应该提供给定的证书路径和密码
  6. 重启服务器

如果重新启动评论堆栈跟踪有任何问题

http://www.mkyong.com/tomcat/how-to-configure-tomcat-to-support-ssl-or-https/

关于java - 本地主机 tomcat 中的安全连接无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31157803/

相关文章:

java - 在 Swing 中使用此关键字有什么问题?

java - 为什么添加字符时会得到不同的结果?

java - JarEntry META-INF/MANIFEST.MF 的大小不受支持

java - 如何改变字符串中字符的位置?

Java LWGJL opengl 缓冲区数据

java - Spring 数据 REST Bean 验证

java - 获取 java.lang.IllegalStateException : Neither BindingResult nor plain target object for bean name 'command' available as request attribute

java - Spring - @Async 在手动创建组件时不起作用

java - Selenide:无法导入其方法

java - 编译引用类构造函数的Maven编译错误