diff options
| -rw-r--r-- | git_config.py | 9 | ||||
| -rw-r--r-- | project.py | 11 | ||||
| -rw-r--r-- | subcmds/upload.py | 7 |
3 files changed, 20 insertions, 7 deletions
diff --git a/git_config.py b/git_config.py index e00f6be2..fb4377cf 100644 --- a/git_config.py +++ b/git_config.py | |||
| @@ -20,6 +20,7 @@ import errno | |||
| 20 | import json | 20 | import json |
| 21 | import os | 21 | import os |
| 22 | import re | 22 | import re |
| 23 | import ssl | ||
| 23 | import subprocess | 24 | import subprocess |
| 24 | import sys | 25 | import sys |
| 25 | try: | 26 | try: |
| @@ -604,7 +605,7 @@ class Remote(object): | |||
| 604 | connectionUrl = self._InsteadOf() | 605 | connectionUrl = self._InsteadOf() |
| 605 | return _preconnect(connectionUrl) | 606 | return _preconnect(connectionUrl) |
| 606 | 607 | ||
| 607 | def ReviewUrl(self, userEmail): | 608 | def ReviewUrl(self, userEmail, validate_certs): |
| 608 | if self._review_url is None: | 609 | if self._review_url is None: |
| 609 | if self.review is None: | 610 | if self.review is None: |
| 610 | return None | 611 | return None |
| @@ -637,7 +638,11 @@ class Remote(object): | |||
| 637 | else: | 638 | else: |
| 638 | try: | 639 | try: |
| 639 | info_url = u + 'ssh_info' | 640 | info_url = u + 'ssh_info' |
| 640 | info = urllib.request.urlopen(info_url).read() | 641 | if not validate_certs: |
| 642 | context = ssl._create_unverified_context() | ||
| 643 | info = urllib.request.urlopen(info_url, context=context).read() | ||
| 644 | else: | ||
| 645 | info = urllib.request.urlopen(info_url).read() | ||
| 641 | if info == 'NOT_AVAILABLE' or '<' in info: | 646 | if info == 'NOT_AVAILABLE' or '<' in info: |
| 642 | # If `info` contains '<', we assume the server gave us some sort | 647 | # If `info` contains '<', we assume the server gave us some sort |
| 643 | # of HTML response back, like maybe a login page. | 648 | # of HTML response back, like maybe a login page. |
| @@ -178,14 +178,16 @@ class ReviewableBranch(object): | |||
| 178 | draft=False, | 178 | draft=False, |
| 179 | private=False, | 179 | private=False, |
| 180 | wip=False, | 180 | wip=False, |
| 181 | dest_branch=None): | 181 | dest_branch=None, |
| 182 | validate_certs=True): | ||
| 182 | self.project.UploadForReview(self.name, | 183 | self.project.UploadForReview(self.name, |
| 183 | people, | 184 | people, |
| 184 | auto_topic=auto_topic, | 185 | auto_topic=auto_topic, |
| 185 | draft=draft, | 186 | draft=draft, |
| 186 | private=private, | 187 | private=private, |
| 187 | wip=wip, | 188 | wip=wip, |
| 188 | dest_branch=dest_branch) | 189 | dest_branch=dest_branch, |
| 190 | validate_certs=validate_certs) | ||
| 189 | 191 | ||
| 190 | def GetPublishedRefs(self): | 192 | def GetPublishedRefs(self): |
| 191 | refs = {} | 193 | refs = {} |
| @@ -1113,7 +1115,8 @@ class Project(object): | |||
| 1113 | draft=False, | 1115 | draft=False, |
| 1114 | private=False, | 1116 | private=False, |
| 1115 | wip=False, | 1117 | wip=False, |
| 1116 | dest_branch=None): | 1118 | dest_branch=None, |
| 1119 | validate_certs=True): | ||
| 1117 | """Uploads the named branch for code review. | 1120 | """Uploads the named branch for code review. |
| 1118 | """ | 1121 | """ |
| 1119 | if branch is None: | 1122 | if branch is None: |
| @@ -1138,7 +1141,7 @@ class Project(object): | |||
| 1138 | branch.remote.projectname = self.name | 1141 | branch.remote.projectname = self.name |
| 1139 | branch.remote.Save() | 1142 | branch.remote.Save() |
| 1140 | 1143 | ||
| 1141 | url = branch.remote.ReviewUrl(self.UserEmail) | 1144 | url = branch.remote.ReviewUrl(self.UserEmail, validate_certs) |
| 1142 | if url is None: | 1145 | if url is None: |
| 1143 | raise UploadError('review not configured') | 1146 | raise UploadError('review not configured') |
| 1144 | cmd = ['push'] | 1147 | cmd = ['push'] |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 61b18bc2..60feff7a 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
| @@ -181,6 +181,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 181 | # Never run upload hooks, but upload anyway (AKA bypass hooks). | 181 | # Never run upload hooks, but upload anyway (AKA bypass hooks). |
| 182 | # - no-verify=True, verify=True: | 182 | # - no-verify=True, verify=True: |
| 183 | # Invalid | 183 | # Invalid |
| 184 | p.add_option('--no-cert-checks', | ||
| 185 | dest='validate_certs', action='store_false', default=True, | ||
| 186 | help='Disable verifying ssl certs (unsafe).') | ||
| 184 | p.add_option('--no-verify', | 187 | p.add_option('--no-verify', |
| 185 | dest='bypass_hooks', action='store_true', | 188 | dest='bypass_hooks', action='store_true', |
| 186 | help='Do not run the upload hook.') | 189 | help='Do not run the upload hook.') |
| @@ -389,7 +392,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
| 389 | draft=opt.draft, | 392 | draft=opt.draft, |
| 390 | private=opt.private, | 393 | private=opt.private, |
| 391 | wip=opt.wip, | 394 | wip=opt.wip, |
| 392 | dest_branch=destination) | 395 | dest_branch=destination, |
| 396 | validate_certs=opt.validate_certs) | ||
| 397 | |||
| 393 | branch.uploaded = True | 398 | branch.uploaded = True |
| 394 | except UploadError as e: | 399 | except UploadError as e: |
| 395 | branch.error = e | 400 | branch.error = e |
