启用SSL的连接器不断出现在server.xml中

问题描述 投票:1回答:3

[每次尝试运行运行正常的Web应用程序之前,我都会不断收到错误消息

 java.lang.IllegalArgumentException: C:\Users\user\.IntelliJIdea2019.2\system\tomcat\projectName\conf\localhost-rsa.jks (The system cannot find the file specified)

所以我深入研究问题并找到了我的server.xml

  <Server port="8090" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true">
      <SSLHostConfig>
        <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" type="RSA" />
      </SSLHostConfig>
    </Connector>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
      </Realm>
      <Host name="localhost" appBase="C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps" unpackWARs="true" autoDeploy="true" deployOnStartup="false" deployIgnore="^(?!(manager)|(tomee)$).*">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
    </Engine>
  </Service>
</Server>

[我认为问题在于存在带有端口8443的连接器元素,该连接器元素引用了证书,因为我不需要https,所以我删除了连接器并从IntelliJ重新启动服务器,但是连接器重新出现,并且我未指定任何内容运行配置中的https端口。我究竟做错了什么 ?我该如何解决?

java tomcat intellij-idea intellij-14 tomcat9
3个回答
0
投票

删除用于处理https的redirectPort="8443"redirectPort

<Connector port="8009" protocol="AJP/1.3" />

当SSL请求到达服务器时,重定向端口将出现,并且由于http连接器端口无法处理SSL请求,它将重定向到定义的端口。


0
投票

检查您的项目应用程序服务器设置。使用运行应用程序的服务器创建新的应用程序服务器。https://www.jetbrains.com/help/idea/configuring-and-managing-application-server-integration.html

我认为您从具有httpd设置的地方获得了代码,您无法弄清楚如何删除它。


0
投票

检查您的项目应用程序服务器设置。使用运行应用程序的服务器创建新的应用程序服务器。https://www.jetbrains.com/help/idea/configuring-and-managing-application-server-integration.html

我认为您从某个具有httpd设置的地方获得了代码,您无法弄清楚如何删除它。检查JKS文件或创建新文件。JKS代表Java KeyStore。它是证书(已签名的公共密钥)和[私有]密钥的存储库。您可以将存储在JKS文件中的证书导出到单独的文件中。您可以使用Java发行版中的“ keytool”实用程序来维护JKS信任关系和密钥存储库。像其他类型的密钥存储库(例如PKCS12,CMS)一样,JKS存储库也受密码保护,因为它可能包含私钥,由于必须使用私钥来解密由公共密钥加密的信息,因此必须加以保护。存储库中的[私有]密钥也受“密钥密码”保护,该密码可能与密钥存储库的密码相同(不是一个好习惯)。

以下命令将在JKS文件“ mykeys.jks”中导出与别名/标签“ mycert”关联的证书。输出文件“ mycert.cer”将仅包含证书(即签名的公共密钥)。

keytool -exportcert -rfc -alias mycert -file mycert.cer -keystore mykeys.jks -storepass passw0rd
© www.soinside.com 2019 - 2024. All rights reserved.