javax.net.ssl.SSLHandshakeException while trying to reach some resources
TwiceII opened this issue · 1 comments
TwiceII commented
Applying the html-resource
function to some recources seems to throw javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
exception.
Is there a way to bypass this, can I provide some option like {:insecure? true}
somewhere?
mishadoff commented
Spent a lot of time with similar issue, found a workaround to disable certificate check.
(defn trust-all-certificates []
(let [trust (into-array javax.net.ssl.TrustManager
[(reify javax.net.ssl.X509TrustManager
(getAcceptedIssuers [this])
(checkClientTrusted [this certs auth])
(checkServerTrusted [this certs auth]))])
sc (javax.net.ssl.SSLContext/getInstance "SSL")]
(.init sc nil trust (java.security.SecureRandom.))
(javax.net.ssl.HttpsURLConnection/setDefaultSSLSocketFactory (.getSocketFactory sc))))