Merge lp:~mwhudson/launchpad/ssl-imports-bug-512763 into lp:launchpad

Proposed by Michael Hudson-Doyle on 2010-02-02
Status: Merged
Approved by: Aaron Bentley on 2010-02-02
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/ssl-imports-bug-512763
Merge into: lp:launchpad
Diff against target: 32 lines (+15/-0)
1 file modified
scripts/code-import-worker.py (+15/-0)
To merge this branch: bzr merge lp:~mwhudson/launchpad/ssl-imports-bug-512763
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2010-02-02 Approve on 2010-02-02
Review via email: mp+18479@code.launchpad.net

Commit message

Force bzrlib to use the urllib transport for code imports, which doesn't choke on self signed certificates

To post a comment you must log in.
Michael Hudson-Doyle (mwhudson) wrote :

This branch forces bzrlib to use the urllib transport for code imports, which has the happy consequence of not failing on self-signed certificates.

Aaron Bentley (abentley) wrote :

Please provide the comment on force_bzr_to_use_urllib as a docstring. Otherwise, this looks good to land.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/code-import-worker.py'
2--- scripts/code-import-worker.py 2010-01-31 23:48:38 +0000
3+++ scripts/code-import-worker.py 2010-02-03 20:40:32 +0000
4@@ -31,6 +31,20 @@
5 from canonical.launchpad import scripts
6
7
8+def force_bzr_to_use_urllib():
9+ """Prevent bzr from using pycurl to connect to http: urls.
10+
11+ We want this because pycurl rejects self signed certificates, which
12+ prevents a significant number of import branchs from updating. Also see
13+ https://bugs.edge.launchpad.net/bzr/+bug/516222.
14+ """
15+ from bzrlib.transport import register_lazy_transport
16+ register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
17+ 'HttpTransport_urllib')
18+ register_lazy_transport('https://', 'bzrlib.transport.http._urllib',
19+ 'HttpTransport_urllib')
20+
21+
22 class CodeImportWorker:
23
24 def __init__(self):
25@@ -40,6 +54,7 @@
26 self.logger = scripts.logger(options, 'code-import-worker')
27
28 def main(self):
29+ force_bzr_to_use_urllib()
30 source_details = CodeImportSourceDetails.fromArguments(self.args)
31 if source_details.rcstype == 'git':
32 load_optional_plugin('git')