Last active
January 18, 2018 16:17
-
-
Save rbobillot/ad28d88e7ff56ba5e530 to your computer and use it in GitHub Desktop.
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
/* | |
** To bypass SSL, just call | |
** SSLBypasser.bypassSSL | |
** in your main | |
*/ | |
object SSLBypasser | |
{ | |
import java.security.cert.X509Certificate | |
import javax.net.ssl._ | |
object AllTM extends X509TrustManager | |
{ | |
def getAcceptedIssuers: Array[X509Certificate] = null | |
def checkClientTrusted(certs: Array[X509Certificate], authType: String){} | |
def checkServerTrusted(certs: Array[X509Certificate], authType: String){} | |
} | |
object AllHosts extends HostnameVerifier | |
{ | |
def verify(urlHostName: String, session: SSLSession) = true | |
} | |
def bypassSSL | |
{ | |
val trustAllCerts = Array[TrustManager](AllTM) | |
val sslContext = SSLContext.getInstance("SSL") | |
sslContext.init(null, trustAllCerts, null); | |
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory) | |
HttpsURLConnection.setDefaultHostnameVerifier(AllHosts); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment