2014-12-19 115 views
2

這來自於Python的「請求」 Python文檔HTTP庫Clojure的SSL指定本地證書作爲客戶端證書

使用「您還可以指定一個本地證書作爲客戶端證書使用,作爲一個單一的文件(包含私鑰和證書),也可以同時文件的路徑的元組「:

>>> requests.get('https://kennethreitz.com', cert=('/path/server.crt', '/path/key')) 
<Response [200]> 

http://docs.python-requests.org/en/latest/user/advanced/

怎樣做同樣的事情在Clojure的一個好辦法嗎?我看着clj-http和http-kit,但沒有看到一個例子

回答

1

你見過async-http-client

它具有針對證書處理的特定測試you can view hereAPI docs are here,特別相關的是命名空間http.async.client.cert

從這個測試,加載密鑰庫和證書的一個典型的例子是:

(def ks-file "test-resources/keystore.jks") 
(def cert-file "test-resources/certificate.crt") 
(def password "secret") 

(defn load-test-certificate [] (load-x509-cert cert-file)) 
(defn load-test-keystore [] (load-keystore (resource-stream ks-file) password)) 
+0

,謝謝,我會給予一個試試吧! –