aboutsummaryrefslogtreecommitdiffstats
path: root/test/tools
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-03-01 21:08:44 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-03-01 21:08:44 +1300
commit533f61f67aab38f5bce882ad0dc03b7b5f292956 (patch)
tree60e02d3cd73a9bfac623db5e1050905cdbb1a158 /test/tools
parent8b841bc9e370370716b473f26e001c65e2eee2af (diff)
downloadmitmproxy-533f61f67aab38f5bce882ad0dc03b7b5f292956.tar.gz
mitmproxy-533f61f67aab38f5bce882ad0dc03b7b5f292956.tar.bz2
mitmproxy-533f61f67aab38f5bce882ad0dc03b7b5f292956.zip
Use PyOpenSSL and PyASN1 for certificate parsing.
Yes, these are two more major dependencies for mitmproxy, but if we're going to do all the cool things I want to do with SSL certs, there is no other way.
Diffstat (limited to 'test/tools')
-rwxr-xr-xtest/tools/getcert17
-rwxr-xr-xtest/tools/getcn12
2 files changed, 9 insertions, 20 deletions
diff --git a/test/tools/getcert b/test/tools/getcert
index dc655958..6447ecc7 100755
--- a/test/tools/getcert
+++ b/test/tools/getcert
@@ -4,21 +4,6 @@ sys.path.insert(0, "../..")
import socket, tempfile, ssl, subprocess
addr = socket.gethostbyname(sys.argv[1])
-s = ssl.get_server_certificate((addr, 443))
-f = tempfile.NamedTemporaryFile()
-f.write(s)
-f.flush()
-p = subprocess.Popen(
- [
- "openssl",
- "x509",
- "-in", f.name,
- "-text",
- "-noout"
- ],
- stdout = subprocess.PIPE
-)
-out, _ = p.communicate()
-print out
+print ssl.get_server_certificate((addr, 443))
diff --git a/test/tools/getcn b/test/tools/getcn
index 4cc028ca..212977c3 100755
--- a/test/tools/getcn
+++ b/test/tools/getcn
@@ -1,10 +1,14 @@
#!/usr/bin/env python
-
import sys
-sys.path.insert(0, "../..")
-from libmproxy import utils
+sys.path.insert(0, "../../")
+from libmproxy import certutils
+
+if len(sys.argv) > 2:
+ port = int(sys.argv[2])
+else:
+ pport = 443
-cn, san = utils.get_remote_cn(sys.argv[1], 443)
+cn, san = certutils.get_remote_cn(sys.argv[1], port)
print cn
if san:
for i in san: