 (defn ^SSLConnectionSocketFactory SSLGenericSocketFactory
   "Given a function that returns a new socket, create an
   SSLConnectionSocketFactory that will use that socket."
-  [socket-factory]
-  (proxy [SSLConnectionSocketFactory] [(SSLContexts/createDefault)]
-    (connectSocket [timeout socket host remoteAddress localAddress context]
-      (let [^SSLConnectionSocketFactory this this] ;; avoid reflection
-        (proxy-super connectSocket timeout (socket-factory) host remoteAddress
-                     localAddress context)))))
+  ([socket-factory] (SSLGenericSocketFactory socket-factory (SSLContexts/createDefault)))
+  ([socket-factory ^SSLContext ssl-context]
+   (proxy [SSLConnectionSocketFactory] [ssl-context]
+     (connectSocket [timeout socket host remoteAddress localAddress context]
+       (let [^SSLConnectionSocketFactory this this] ;; avoid reflection
+         (proxy-super connectSocket timeout (socket-factory) host remoteAddress
+                      localAddress context))))))
 
 (defn ^PlainConnectionSocketFactory PlainGenericSocketFactory
   "Given a Function that returns a new socket, create a

     :verifier (if (opt req :insecure)
                 NoopHostnameVerifier/INSTANCE
                 (DefaultHostnameVerifier.))}))

(defn ^Registry get-keystore-scheme-registry
  [req]

  "Create a Socket proxied through socks, using the given hostname and port"
  [^String hostname ^Integer port]
  (Socket. (Proxy. Proxy$Type/SOCKS (InetSocketAddress. hostname port))))

(defn ^KeyStore get-keystore*
  [keystore-file keystore-type ^String keystore-pass]
