Created
February 4, 2022 10:23
-
-
Save stevenklar/69887e618f24bd957aa47fbaa3dfbcda to your computer and use it in GitHub Desktop.
SSL Pin checker
This file contains hidden or 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
| #!/usr/bin/env kscript | |
| //DEPS com.squareup.okhttp3:okhttp:4.9.0 | |
| import java.io.IOException; | |
| import okhttp3.OkHttpClient; | |
| import okhttp3.CertificatePinner | |
| import okhttp3.Response; | |
| import okhttp3.Interceptor | |
| import okhttp3.Request | |
| if (args.size != 2) { | |
| System.err.println("Usage: sslpin <domain> <pin>") | |
| kotlin.system.exitProcess(-1) | |
| } | |
| val hostname = args[0] | |
| var pin = args[1] | |
| val certificatePinner = CertificatePinner.Builder() | |
| .add(hostname, "sha256/" + pin) | |
| .build(); | |
| val client = OkHttpClient.Builder() | |
| .certificatePinner(certificatePinner) | |
| .build(); | |
| val request = Request.Builder() | |
| .url("https://" + hostname) | |
| .build(); | |
| try { | |
| client.newCall(request).execute(); | |
| println("OK") | |
| } catch (e: Exception) { | |
| println(e) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Mac just: