#1484·wiremock

WireMock 不允许不同类型的 KeyStore 和 TrustStore

作者: billabercrombie创建于 2021年5月11日更新于 2026年8月27日
标签enhancementhelp wanted

我正在尝试创建一个 WireMock 配置: `WireMockServer wireMockServer = new WireMockServer(wireMockConfig() .httpsPort(8443) .needClientAuth(true) .trustStorePath(System.getProperty("javax.net.ssl.trustStore")) .trustStorePassword(System.getProperty("javax.net.ssl.trustStorePassword")) .trustStoreType(System.getProperty("javax.net.ssl.trustStoreType")) .keyStorePath(System.getProperty("javax.net.ssl.keyStore")) .keyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword")) .keyStoreType(System.getProperty("javax.net.ssl.keyStoreType")));` ` `wireMockServer.start()` 其中,trustStoreType 设置为 "JKS",keyStoreType 设置为 "pkcs12"。 当这样做时,我收到了以下错误: `java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big。` 追踪此问题,它是从 `org.eclipse.jetty.util.ssl.SslContextFactory.loadTrustStore(Resource resource)` 方法中抛出的。 此方法查找 trustStoreType,如果为空,则在尝试加载存储时使用 keyStoreType。 在我的情况下,trustStoreType 为空,尽管我在配置中设置了它。 因此在这种情况下,它使用 trustStorePath、trustStorePassword 和 keyStoreType 尝试加载 truststore,这导致了异常。 我认为 trustStoreType 为空的原因发生在 `com.GitHub.tomakehurst.wiremock.jetty94.SslContexts.setupClientAuth(SslContextFactory.Server sslContextFactory, HttpsSettings httpsSettings)` 方法中。 在该方法中,当 httpsSettings 具有 trustStore 时,路径和密码被设置,但类型未设置。 我认为需要在该处设置 trustStoreType,以允许不同于 keyStoreType 的 trustStoreType。 你能确认这是一个 bug 吗?如果不是 bug,你能推荐使用不同类型的 trustStore 和 keyStore 的方法吗? 感谢!

内容来源: wiremock/wiremock