Skip to content

Instantly share code, notes, and snippets.

@stevenklar
Created February 4, 2022 10:23
Show Gist options
  • Select an option

  • Save stevenklar/69887e618f24bd957aa47fbaa3dfbcda to your computer and use it in GitHub Desktop.

Select an option

Save stevenklar/69887e618f24bd957aa47fbaa3dfbcda to your computer and use it in GitHub Desktop.
SSL Pin checker
#!/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)
}
@stevenklar
Copy link
Author

stevenklar commented Feb 4, 2022

For Mac just:

brew install holgerbrandl/tap/kscript
./sslpin.kts domain.de AAA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment