Created
July 24, 2019 10:32
-
-
Save djtango/0097d6d0cc5cd389330d9982a8d959a9 to your computer and use it in GitHub Desktop.
recipe for SSL configuration with httpkit to solve javax.net.ssl.SSLException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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