gpt4 book ai didi

wiremock - 使wiremock接受任何证书

转载 作者:行者123 更新时间:2023-12-03 23:22:59 35 4
gpt4 key购买 nike

我在wiremock中定义了一个https stub ,如下所示:-

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));
}
}

每当我向 https://localhost:8443/oms-api/ 发送 POST 请求时我收到以下异常:-
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

是否可以告诉 WireMock 接受任何证书?我在 wiremock 1.58java 1.8 .

最佳答案

正如所讨论的 here ,问题不在 Wiremock 方面,而是客户端代码拒绝 WireMock 的自签名证书(这是正确的,因为客户端未配置为使用 Wiremock 证书。)。

关于wiremock - 使wiremock接受任何证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36965751/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com