0

我们正在使用clj-http由带有自签名证书的 keystore.pfx 组成的密钥库:

(let [url (str url "api/fetch")
      opts {:keystore "keystore.pfx"
            :keystore-type "pkcs12"
            :keystore-pass "****"
            :body (json/encode {:method "yada"})
            :content-type :json
            :throw-entire-message? true
            :async? false}
      response (http/post url opts)]
  (-> response
      :body
      base64-decode))

使用密钥库的 API 调用在本地工作以使用客户端证书调用 API,但不适用于 Kubernetes 上的 Docker。

例外是:

sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径

任何想法如何解决?我们是否需要以某种方式将其添加到 JVM 中?如果是这样,在哪里以及如何添加 pfx?

4

1 回答 1

2

您的自签名客户端/服务器证书不共享信任链(这是错误消息告诉您的内容)。

将 CA 证书放在信任库中,例如

keytool -importcert -noprompt -alias ca -file ca.crt -keystore truststore -storepass secret

并将信任库添加到请求中:

  ; ...
  :trust-store "truststore"  ; XXX
  :trust-store-pass "secret" ; XXX
  :keystore "keystore.pfx"
  :keystore-pass "****"
  ; ...
于 2019-12-20T11:11:10.137 回答