Merge lp:~cr3/checkbox/transport into lp:checkbox

Proposed by Marc Tardif
Status: Merged
Merged at revision: 1078
Proposed branch: lp:~cr3/checkbox/transport
Merge into: lp:checkbox
Diff against target: 77 lines (+23/-6)
3 files modified
checkbox/lib/transport.py (+14/-4)
debian/changelog (+3/-0)
plugins/launchpad_exchange.py (+6/-2)
To merge this branch: bzr merge lp:~cr3/checkbox/transport
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+77376@code.launchpad.net
To post a comment you must log in.
lp:~cr3/checkbox/transport updated
1078. By Marc Tardif

Added checking for exception when exchanging in case the certificate is invalid.

Revision history for this message
Daniel Manrique (roadmr) wrote :

Looks OK, merging. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox/lib/transport.py'
2--- checkbox/lib/transport.py 2011-09-14 19:18:06 +0000
3+++ checkbox/lib/transport.py 2011-09-28 18:22:26 +0000
4@@ -19,6 +19,7 @@
5 import logging
6
7 import os
8+import re
9 import stat
10 import sys
11 import posixpath
12@@ -133,19 +134,28 @@
13 timeout = None
14 _tunnel_host = None
15
16+ def match_name(self, name):
17+ parts = []
18+ for fragment in name.split(r"."):
19+ if fragment == "*":
20+ parts.append(".+")
21+ else:
22+ fragment = re.escape(fragment)
23+ parts.append(fragment.replace(r"\*", ".*"))
24+ return re.match(r"\A" + r"\.".join(parts) + r"\Z", self.host, re.IGNORECASE)
25+
26 def verify_cert(self, cert):
27- # verify that the hostname exactly matches that of the certificate,
28- # wildcards in the certificate hostname are not supported
29+ # verify that the hostname matches that of the certificate
30 if cert:
31 san = cert.get("subjectAltName", ())
32 for key, value in san:
33- if key == "DNS" and value == self.host:
34+ if key == "DNS" and self.match_name(value):
35 return True
36
37 if not san:
38 for subject in cert.get("subject", ()):
39 for key, value in subject:
40- if key == "commonName" and value == self.host:
41+ if key == "commonName" and self.match_name(value):
42 return True
43
44 return False
45
46=== modified file 'debian/changelog'
47--- debian/changelog 2011-09-28 18:20:25 +0000
48+++ debian/changelog 2011-09-28 18:22:26 +0000
49@@ -31,6 +31,9 @@
50 each time (LP: #855845)
51 (LP: #852201)
52
53+ [Marc Tardif]
54+ * Added support for wildcards when verifying the transport certificate.
55+
56 [Tim Chen]
57 * Fix cpu_scaling_test (LP: #811177)
58
59
60=== modified file 'plugins/launchpad_exchange.py'
61--- plugins/launchpad_exchange.py 2011-08-31 16:47:02 +0000
62+++ plugins/launchpad_exchange.py 2011-09-28 18:22:26 +0000
63@@ -139,8 +139,12 @@
64
65 transport = HTTPTransport(self.transport_url)
66 start_time = time.time()
67- response = transport.exchange(form, self._headers,
68- timeout=string_to_type(self.timeout))
69+ try:
70+ response = transport.exchange(form, self._headers,
71+ timeout=string_to_type(self.timeout))
72+ except Exception, error:
73+ self._manager.reactor.fire("exchange-error", error)
74+ return
75 end_time = time.time()
76
77 if not response:

Subscribers

People subscribed via source and target branches