As I haven't found a way, I went for com.github.tomakehurst.wiremock.WireMockServer which works pretty good. Here is how I set it up, please note that I needed to add keyManagerPassword as well (I'm not sure why, but it's simply the one of the keystore)
public WireMockServer mutualTlsMock;
@BeforeEach
void setUp() {
mutualTlsMock = new WireMockServer(options()
.httpsPort(8443)
.needClientAuth(true)
.keystorePath("path/to/my/keystore.jks")
.keystorePassword("keystorePassword")
.keyManagerPassword("keystorePassword")
.trustStorePath("path/to/my/keystore.jks")
.trustStorePassword("keystorePassword"));
mutualTlsMock.start();
}
@AfterEach
void shutdown() {
mutualTlsMock.shutdown();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…