我尝试使用aleph连接到经过相互身份验证的Docker守护程序。 aleph文档显示您可以传入netty SSL上下文以进行身份验证。我似乎正确地创建了SslContext,但所有请求都已关闭
(require '[aleph.http :as http])
(import '[io.netty.handler.ssl SslContext])
(import '[io.netty.handler.ssl SslProvider])
(import '[io.netty.handler.ssl SslContextBuilder])
(def ctx
(doto (SslContextBuilder/forClient)
(.keyManager (java.io.File. "certs/cert.pem")
(java.io.File. "certs/client.pkcs8"))
(.trustManager (java.io.File. "certs/ca.pem"))
(.build)))
(let [pool (http/connection-pool {:connection-options {:ssl-context ctx}})]
@(http/get (str "http://" host ":" port "/info") {:pool pool}))
结果:" ExceptionInfo连接已关闭clojure.core / ex-info(core.clj:4617)"
有没有人找到使用TLS连接的好方法?我尝试了https://github.com/aphyr/less-awful-ssl,但这并不适用于netty。帮助thnx!
答案 0 :(得分:0)
发现我正在创建错误的SslContext对象。应该像:
(def ctx
(.build
(.keyManager
(.trustManager (SslContextBuilder/forClient) ca)
cert client-key)))
;; pass in ssl-context via pool
(let [pool (http/connection-pool {:connection-options {:ssl-context ctx}})]
(-> @(http/get (str "https://" host ":" port "/info") {:pool pool})
:body
bs/to-string))