Spring Boot 2嵌入tomcat 9.0.26无法加载jks文件流关闭


11

我尝试在嵌入了tomcat 9.0.26的Spring Boot 2.2.0上使用SSL,但是tomcat无法关闭JKS文件流。

这是应用程序属性:

server.port=443
server.ssl.key-store-type=JKS
server.ssl.key-store=C:\\Keystore\\mykey.jks
server.ssl.key-store-password=cccc 
server.ssl.key-alias=*.mydomain.com

例外:

org.springframework.boot.web.server.WebServerException:无法在org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:215)〜[spring-boot-2.2.0上启动嵌入式Tomcat服务器。 ..BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297)〜[spring-boot-2.2.0。 BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT],位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163)〜[spring-boot-2.2.0.BUILD -SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)〜[spring-context-5.2.0.RELEASE。jar!/:5.2.0.RELEASE]位于org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/ :2.2.0.BUILD-SNAPSHOT]在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD- SNAPSHOT],网址为org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]。 boot.SpringApplication.run(SpringApplication.java:315)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]在org.springframework.boot.SpringApplication.run(SpringApplication .java:1226)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0。BUILD-SNAPSHOT],位于欧盟org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]。 soluma.app.SolumaTdvApplication.main(SolumaTdvApplication.java:34)〜[classes!/:0.0.1-SNAPSHOT] at java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:na]在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:na]在java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜 na:na]在java.base / java.lang.reflect.Method.invoke(Method.java:567)〜[na:na]在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 〜[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0。org.springframework.boot.loader.Launcher.launch(Launcher.java:87)的[1-SNAPSHOT]〜org.springframework.boot.loader中的[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]。 Launcher.launch(Launcher.java:51)〜[SolumaTDV-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)〜[SolumaTDV -0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]由以下原因引起:java.lang.IllegalArgumentException:standardService.connector.startFailed at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231)〜[ tomcat-embed-core-9.0.26.jar!/:9.0.26],位于org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:278)〜[spring-boot-2.2.0 ..BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT]位于org.springframework.boot。web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:197)〜[spring-boot-2.2.0.BUILD-SNAPSHOT.jar!/:2.2.0.BUILD-SNAPSHOT] ...省略了18个常见框架创建人:org.apache.catalina.LifecycleException:协议处理程序启动失败,发生在org.apache.catalina.connector.Connector.startInternal(Connector.java:1008)〜[tomcat-embed-core-9.0.26.jar!/:9.0 .26]在org.apache.catalina.core上的org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] .StandardService.addConnector(StandardService.java:227)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] ...省略了20个常见框架导致原因:java.lang.IllegalArgumentException:流在以下位置关闭org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:99)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71)〜[tomcat-embed-core -9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:218)〜[tomcat-embed-core-9.0.26.jar!/: 9.0.26],位于org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1124)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26],位于org.apache。 tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1210)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java :585)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.catalina.connector.Connector.startInternal(Connector.java:1005)〜[tomcat-embed-core- 9.0.26.jar!/:9.0。[26] ... ...省略了22个共同的框架导致原因:java.io.IOException:流在java.base / java.base / java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:176)〜[na:na]关闭java.io/java.io.BufferedInputStream.fill(BufferedInputStream.java:342)〜[na:na] /java.base/中的java.io.BufferedInputStream.fill(BufferedInputStream.java:252)〜[na:na] java.io/java.security.DigestInputStream.read(DigestInputStream.java:125)〜[na:na]的java.io.BufferedInputStream.read(BufferedInputStream.java:271)〜[na:na] java.io/java.io.DataInputStream.readInt(DataInputStream.java:392)〜[na:na]〜java中的java.base / sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:659)〜[na:na]。 base / sun.security.util.KeyStoreDelegator。engineLoad(KeyStoreDelegator.java:222)〜[na:na]在java.base / java.security.KeyStore.load(KeyStore.java:1472)〜[na:na]在org.apache.tomcat.util.security中。 KeyStoreUtil.load(KeyStoreUtil.java:69)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:217 )〜[tomcat-embed-core-9.0.26.jar!/:9.0.26]在org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:206)〜[tomcat-embed-core- 9.0.26.jar!/:9.0.26],位于org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:283)〜[tomcat-embed-core-9.0.26.jar!/:9.0 .26]在org.apache.tomcat的org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:247)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] .util.net。AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:97)〜[tomcat-embed-core-9.0.26.jar!/:9.0.26] ...省略了28个常见框架


您是否尝试过将密钥库的路径放在“双引号”中并使用单斜杠?例如server.ssl.key-store="C:\Keystore\mykey.jks"
Tommy Brettschneider,

您是否尝试过在位置加上前缀file:
M. Deinum

是的,我尝试了两种技巧,但没有运气
user2803095

到底是什么问题?
TylerH

Answers:



7

谢谢佩德罗。我遇到了Spring Boot 2.1.9.RELEASE的问题,可以通过降级到2.1.8来确认它已解决。


Java 12以及从Spring 2.1.9.RELEASE到2.1.8.RELEASE的版本也对我有用。
Markus G.19年

...佩德罗是谁?
TylerH

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.