MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
configure a ClientAndServer with mTLS and client cert authentication
note: outbound TLS not required
MockServer version
The version you are using
mockserver-netty, mockserver-client-java: 5.15.0
To Reproduce
@BeforeAll
static void setUp() {
ConfigurationProperties.certificateAuthorityCertificate("keys/server-subca.crt");
ConfigurationProperties.certificateAuthorityPrivateKey("keys/server-subca.key");
ConfigurationProperties.x509CertificatePath("keys/server-server.crt");
ConfigurationProperties.privateKeyPath("keys/server-server.key");
ConfigurationProperties.tlsMutualAuthenticationRequired(true);
ConfigurationProperties.tlsMutualAuthenticationCertificateChain("keys/server-truststore.pem");
// outbound TLS not needed
// ConfigurationProperties.forwardProxyTLSCustomTrustX509Certificates
// ConfigurationProperties.forwardProxyCertificateChain
// ConfigurationProperties.forwardProxyPrivateKey
// now server will start and can be connected to by openssl s_client
mockServer = ClientAndServer.startClientAndServer(12350);
// this rule causes an error
mockServer.when(request().withMethod("GET").withPath("/api/any/test"))
.respond(response().withStatusCode(200).withDelay(TimeUnit.MILLISECONDS, 100)
.withHeader("Content-Type", "application/json").withBody("{\"status\":\"test OK\"}"));
How you are running MockServer (i.e maven plugin, docker, etc): Java code in JUnit @BeforeAll
Code you used to create expectations: see above
What error you saw: Creating the expection causes 426
Expected behaviour
Configure ClientAndServer with when(...) expectations
MockServer Log
Log output, as INFO level (or lower)
Describe the issue After starting a mTLS ClientAndServer, the first
when(...)
rule causesClientException
termination withWhat you are trying to do
MockServer version The version you are using mockserver-netty, mockserver-client-java: 5.15.0
To Reproduce
@BeforeAll
Expected behaviour Configure ClientAndServer with
when(...)
expectationsMockServer Log Log output, as INFO level (or lower)