summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git_config.py9
-rw-r--r--project.py11
-rw-r--r--subcmds/upload.py7
3 files changed, 20 insertions, 7 deletions
diff --git a/git_config.py b/git_config.py
index 8c247394..8f666e6d 100644
--- a/git_config.py
+++ b/git_config.py
@@ -20,6 +20,7 @@ import errno
20import json 20import json
21import os 21import os
22import re 22import re
23import ssl
23import subprocess 24import subprocess
24import sys 25import sys
25try: 26try:
@@ -612,7 +613,7 @@ class Remote(object):
612 connectionUrl = self._InsteadOf() 613 connectionUrl = self._InsteadOf()
613 return _preconnect(connectionUrl) 614 return _preconnect(connectionUrl)
614 615
615 def ReviewUrl(self, userEmail): 616 def ReviewUrl(self, userEmail, validate_certs):
616 if self._review_url is None: 617 if self._review_url is None:
617 if self.review is None: 618 if self.review is None:
618 return None 619 return None
@@ -645,7 +646,11 @@ class Remote(object):
645 else: 646 else:
646 try: 647 try:
647 info_url = u + 'ssh_info' 648 info_url = u + 'ssh_info'
648 info = urllib.request.urlopen(info_url).read() 649 if not validate_certs:
650 context = ssl._create_unverified_context()
651 info = urllib.request.urlopen(info_url, context=context).read()
652 else:
653 info = urllib.request.urlopen(info_url).read()
649 if info == 'NOT_AVAILABLE' or '<' in info: 654 if info == 'NOT_AVAILABLE' or '<' in info:
650 # If `info` contains '<', we assume the server gave us some sort 655 # If `info` contains '<', we assume the server gave us some sort
651 # of HTML response back, like maybe a login page. 656 # of HTML response back, like maybe a login page.
diff --git a/project.py b/project.py
index e700d16a..4eca9b67 100644
--- a/project.py
+++ b/project.py
@@ -179,14 +179,16 @@ class ReviewableBranch(object):
179 draft=False, 179 draft=False,
180 private=False, 180 private=False,
181 wip=False, 181 wip=False,
182 dest_branch=None): 182 dest_branch=None,
183 validate_certs=True):
183 self.project.UploadForReview(self.name, 184 self.project.UploadForReview(self.name,
184 people, 185 people,
185 auto_topic=auto_topic, 186 auto_topic=auto_topic,
186 draft=draft, 187 draft=draft,
187 private=private, 188 private=private,
188 wip=wip, 189 wip=wip,
189 dest_branch=dest_branch) 190 dest_branch=dest_branch,
191 validate_certs=validate_certs)
190 192
191 def GetPublishedRefs(self): 193 def GetPublishedRefs(self):
192 refs = {} 194 refs = {}
@@ -1114,7 +1116,8 @@ class Project(object):
1114 draft=False, 1116 draft=False,
1115 private=False, 1117 private=False,
1116 wip=False, 1118 wip=False,
1117 dest_branch=None): 1119 dest_branch=None,
1120 validate_certs=True):
1118 """Uploads the named branch for code review. 1121 """Uploads the named branch for code review.
1119 """ 1122 """
1120 if branch is None: 1123 if branch is None:
@@ -1139,7 +1142,7 @@ class Project(object):
1139 branch.remote.projectname = self.name 1142 branch.remote.projectname = self.name
1140 branch.remote.Save() 1143 branch.remote.Save()
1141 1144
1142 url = branch.remote.ReviewUrl(self.UserEmail) 1145 url = branch.remote.ReviewUrl(self.UserEmail, validate_certs)
1143 if url is None: 1146 if url is None:
1144 raise UploadError('review not configured') 1147 raise UploadError('review not configured')
1145 cmd = ['push'] 1148 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