Rob Buhler
Rob Buhler

Reputation: 2511

Clojure SSL specify local cert to use as a client side certificate

This comes from the python documentation for Python "Requests" http library

"You can also specify a local cert to use as client side certificate, as a single file (containing the private key and the certificate) or as a tuple of both file’s path":

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

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

What's a good way to do the same thing in Clojure ? I looked at clj-http and http-kit but did not see an example

Upvotes: 2

Views: 1256

Answers (1)

Mark Fisher
Mark Fisher

Reputation: 9886

Have you seen async-http-client?

It has specific tests for cert handling you can view here. The API docs are here, particularly relevant would be the namespace http.async.client.cert.

From that test, a typical example of loading keystore and certificate is:

(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))

Upvotes: 1

Related Questions