Make wiremock accept any certificate
See original GitHub issueHi,
I have defined a https stub in wiremock as follows:-
public class HttpsMockMain {
public static void main(String[] args) {
WireMockServer mockServer = new WireMockServer(56789, 8443);
addStub(mockServer);
mockServer.start();
}
private static void addStub(WireMockServer mockServer) {
ResponseDefinitionBuilder responseBuilder = aResponse().withStatus(200).withBody(
"{\"message\":null,\"httpStatus\":0,\"status\":{\"httpStatusCode\":200,\"success\":true,\"errors\":[]},\"_metaData\":{\"urlParams\":{}},\"debugData\":null,\"data\":[\"01125851014\",\"01125851014\",\"debraj.manna@jabong.com\",\"03325853088\",\"03325853088\",\"debraj.manna@rediffmail.com\"],\"httpStatusToBeReturned\":200}");
mockServer.stubFor(post(urlPathEqualTo("/oms-api/")).willReturn(responseBuilder));
}
}
Whenever I am sending a POST request to https://localhost:8443/oms-api/
I am getting the below exception:-
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Is it possible to tell WireMock to accept any certificate? I am on wiremock 1.58
and java 1.8
Issue Analytics
- State:
- Created 7 years ago
- Comments:11
Top Results From Across the Web
Make wiremock accept any certificate - Stack Overflow
You are using WireMock's default (self-signed) TLS certificate or another certificate that isn't signed by a CA. In this case you need to...
Read more >https - WireMock
WireMock can optionally accept requests over HTTPS. ... To make WireMock require clients to authenticate via a certificate you need to supply a...
Read more >Make wiremock accept any certificate · Issue #396 - GitHub
Create your own keystore + certificate which is trusted by your HTTP client and tell WireMock to use that (you'll need to use...
Read more >How to make wiremock accept any certificate - Google Groups
Hi, The wiremock gives me below exception : java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: sun.security.validator.
Read more >Creating a TLS connection with Wiremock - Medium
cnf file with all the required details to generate a self-signed certificate. STEP 2: Once you create the .cnf file, run the following...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah, so this is coming from your calling code.
Unfortunately, this isn’t an issue with WireMock, it’s your client code rejecting WireMock’s self-signed certificate (which it will rightly do, unless you’ve explicitly configured it otherwise). You have a couple of options here:
keystore
file in the root of the WireMock JAR.wireMockConfig()
style of constructor forWireMockServer
)@afilina it depends which HTTP client you’re using, but you can do it with the Apache client like this: https://github.com/tomakehurst/wiremock/blob/master/src/test/java/com/github/tomakehurst/wiremock/HttpsAcceptanceTest.java#L301