#1484·wiremock

WireMock doesn't allow KeyStore and TrustStore of different types

Author: billabercrombieCreated May 11, 2021Updated Aug 27, 2026
Labelsenhancementhelp wanted

I am trying to create a WireMock configuration:

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()

Where the trustStoreType is set to "JKS" and the keyStoreType is set to "pkcs12".

When doing this, I receive the error:

java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.

Tracing the issue, it is being thrown from the org.eclipse.jetty.util.ssl.SslContextFactory.loadTrustStore(Resource resource) method. This method looks for the trustStoreType, and if that is null it uses the keyStoreType when it tries to load the store. In my scenario, the trustStoreType is null even though I set it in the configuration. So in this case, it is using the trustStorePath, trustStorePassword, and keyStoreType to try to load the truststore and this throws the exception.

I believe the reason that the trustStoreType is null occurs in the com.github.tomakehurst.wiremock.jetty94.SslContexts.setupClientAuth(SslContextFactory.Server sslContextFactory, HttpsSettings httpsSettings) method. In that method, when the httpsSettings have a trustStore, the path and the password are set but the type is not set. I believe the trustStoreType needs to be set here in order to allow a trustStoreType that is different than the keyStoreType.

Can you verify if this is a bug? If it is not a bug can you recommend a way to use a trustStore and keyStore of different types?

Thank you!