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



当我试图运行我的web应用程序时,它在我不断收到错误之前运行良好

java.lang.IllegalArgumentException: C:Usersuser.IntelliJIdea2019.2systemtomcatprojectNameconflocalhost-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 FilesApache Software FoundationTomcat 9.0webapps" 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端口。我做错了什么?我该怎么解决这个问题?

删除用于处理https 的重定向端口redirectPort="8443"

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

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

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

我想你从某个有httpd设置的地方得到了代码,但你不知道如何删除它。

检查您的项目应用程序服务器设置。创建新的应用程序服务器,使用该服务器运行应用程序。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

最新更新