【问题标题】:SSLHandshakeException when connecting to Wiremock with my own self-signed cert使用我自己的自签名证书连接到 Wiremock 时出现 SSLHandshakeException
【发布时间】:2020-02-17 11:29:15
【问题描述】:

我正在运行一个独立的 Wiremock 实例,用于在 JUnit 测试中进行模拟。这适用于 http,如果我使用带有开关 --https-port 8443 的wiremock自签名证书。但是,如果我指定 --https-keystore server_keystore.jks,任何与 Wiremock 通信的尝试,例如 WireMock.reset(); 都会抛出 javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake。在浏览器中连接到管理页面 https://localhost:9093/__admin/ 会显示有关连接被关闭的类似错误。

keystore 生成如下;

keytool -genkey -keyalg RSA -keysize 2048 -alias server -keypass secret -storepass secret -keystore server_keystore.jks

如果我为 Wiremock 中的所有流量启用日志记录,我会看到;

Problem decoding network traffic
java.nio.charset.MalformedInputException: Input length = 1

在尝试与 Wiremock 通信但未成功之前,我在调用代码中添加了 System.setProperty("javax.net.ssl.trustStore", "server_keystore.jks");

【问题讨论】:

    标签: wiremock wiremock-standalone


    【解决方案1】:

    由于您已在密钥库上设置了密码,因此您需要通过 --keystore-password 参数将其提供给 WireMock。

    【讨论】:

    • 对不起,我没有提到这一点,但我已经包含了密码参数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 2018-10-12
    • 2014-08-05
    • 2014-10-02
    • 2022-08-18
    相关资源
    最近更新 更多