1

Java が PKCS#11 HSM ベースのキーストアを使用できるようにするための標準的な構成は、キーストア パスに何も構成せず (null のままにする)、Java セキュリティを構成して PKCS 11 セキュリティ プロバイダーを取得することです。詳細情報 (Sun/Oracle JVM を使用) は、こちらから入手できます。キーストアに関する Java ドキュメントの指定 - 空のキーストアを作成する場合、またはストリームからキーストアを初期化できない場合は、ストリーム引数として null を渡します。(参照:こちら) ただし、Spring Boot でこれを行うと、次の例外が発生します。

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is
java.lang.IllegalArgumentException: Resource location must not be null
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at com.example.manager.ManagerApplication.main(ManagerApplication.java:27) [axon-manager-ws-0.3.2-SNAPSHOT.jar:0.3.2-SNAPSHOT] Caused by:
java.lang.IllegalArgumentException: Resource location must not be null
        at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
        at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:131) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSslKeyStore(TomcatEmbeddedServletContainerFactory.java:329) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureSsl(TomcatEmbeddedServletContainerFactory.java:312) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.customizeSsl(TomcatEmbeddedServletContainerFactory.java:278) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.customizeConnector(TomcatEmbeddedServletContainerFactory.java:257) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:159) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
        ... 8 more

クラス「org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory」では、キーストア パスを null にすることが許可されていないようです。指定されたパスからリソースをロードしようとします。

Spring Boot のバージョンは 1.3.0 です。私は最新バージョンを見ましたhttps://github.com/spring-projects/spring-boot/blob/master/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory .javaとコードは変更されていないようです (行 343) 興味深いことに、コードがトラスト ストアをロードしようとすると、十分に保護されます (ヌルのトラスト ストア パスを許可します)。行 358 を参照してください。

これは簡単な修正です。キーストア パスが null および/または空であるかどうかを確認し、そのままにしておきます。

これを解決しようとしている他の人には、「org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory」の「configureSsl」メソッドをオーバーライドし、アプリケーション構成でこのインスタンスを EmbeddedServletContainerFactory に構成するという回避策があります。

問題は、TomcatEmbeddedServletContainerFactory をオーバーライドする必要がないように、Spring Boot でセキュリティ/キーストアを構成する別の方法はありますか? または、Spring Boot での問題のログ記録を検討し、パッチを提案する必要がありますか?

4

0 に答える 0