]> andersk Git - jira-zephyrbot.git/blobdiff - urllib-cert.py
More implementations.
[jira-zephyrbot.git] / urllib-cert.py
diff --git a/urllib-cert.py b/urllib-cert.py
new file mode 100644 (file)
index 0000000..3781026
--- /dev/null
@@ -0,0 +1,26 @@
+import urllib2
+import httplib
+
+cert_file = "cert.pem"
+key_file = cert_file
+
+class HTTPSCertConnection(httplib.HTTPSConnection):
+    def __init__(self, host):
+        httplib.HTTPSConnection.__init__(self, host, None, key_file, cert_file)
+
+class HTTPSCertHandler(urllib2.HTTPSHandler):
+    def do_open(self, http_class, req):
+        if http_class is httplib.HTTPSConnection:
+            http_class = HTTPSCertConnection
+        return urllib2.HTTPSHandler.do_open(self, http_class, req)
+
+opener = urllib2.build_opener(urllib2.HTTPRedirectHandler, HTTPSCertHandler)
+urllib2.install_opener(opener)
+
+#req = urllib2.Request(url='https://geofft.scripts.mit.edu:444/detect.php')
+#f = urllib2.urlopen(req)
+#print f.read()
+
+req = urllib2.Request(url='https://jira.mit.edu/jira/secure/mit_login.jsp?os_destination=/secure/Dashboard.jspa')
+print urllib2.urlopen(req).read()
+
This page took 0.077527 seconds and 4 git commands to generate.