Skip to content

Instantly share code, notes, and snippets.

@djtango
Created July 24, 2019 10:32
Show Gist options
  • Save djtango/0097d6d0cc5cd389330d9982a8d959a9 to your computer and use it in GitHub Desktop.
Save djtango/0097d6d0cc5cd389330d9982a8d959a9 to your computer and use it in GitHub Desktop.
recipe for SSL configuration with httpkit to solve javax.net.ssl.SSLException
(ns httpkit-ssl
"recipe for SSL configuration with httpkit if you get javax.net.ssl.SSLException on Java 8
more info: https://github.com/http-kit/http-kit/issues/334"
(:require [org.httpkit.client :as http])
(:import (java.net URI)
(javax.net.ssl SSLEngine
SSLParameters
SNIHostName)))
(defn sni-configure
[^SSLEngine ssl-engine ^URI uri]
(let [^SSLParameters ssl-params (.getSSLParameters ssl-engine)]
(.setServerNames ssl-params [(SNIHostName. (.getHost uri))])
(.setSSLParameters ssl-engine ssl-params)))
(def client (http/make-client {:ssl-configurer sni-configure}))
(comment
(http/post url {:client client ,,,})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment