Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created October 24, 2011 21:26
Show Gist options
  • Save pcarrier/1310364 to your computer and use it in GitHub Desktop.
Save pcarrier/1310364 to your computer and use it in GitHub Desktop.
(ns moob.sslbs
(:import (java.io InputStreamReader Reader)
(java.net URL
URLConnection)
(javax.net.ssl HostnameVerifier HttpsURLConnection
SSLContext SSLSession TrustManager
X509TrustManager)
(java.security cert.X509Certificate SecureRandom)))
(defn disable
[]
(let [ tm (into-array TrustManager
[(proxy [X509TrustManager]
[]
(getAcceptedIssuers [] nil)
(checkClientTrusted [certs auth-type])
(checkServerTrusted [certs auth-type]))])
sslctx (SSLContext/getInstance "SSL")
]
(.init sslctx nil tm (SecureRandom.))
(HttpsURLConnection/setDefaultSSLSocketFactory (.getSocketFactory sslctx))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment