13547: make the Python SDK respect the ARVADOS_API_HOST_INSECURE environment
authorWard Vandewege <wvandewege@veritasgenetics.com>
Wed, 30 May 2018 20:03:59 +0000 (16:03 -0400)
committerWard Vandewege <wvandewege@veritasgenetics.com>
Wed, 30 May 2018 20:03:59 +0000 (16:03 -0400)
variable when speaking with keep over SSL

refs #13547

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <wvandewege@veritasgenetics.com>

sdk/python/arvados/keep.py

index e8e95afc7013650c67e753a3f2de4e7ec227fc44..1150bb6b4e52741e13fbfa3f1aa4f5935cb3468a 100644 (file)
@@ -371,6 +371,8 @@ class KeepClient(object):
                         '{}: {}'.format(k,v) for k,v in self.get_headers.items()])
                     curl.setopt(pycurl.WRITEFUNCTION, response_body.write)
                     curl.setopt(pycurl.HEADERFUNCTION, self._headerfunction)
+                    if self.insecure:
+                        curl.setopt(pycurl.SSL_VERIFYPEER, 0)
                     if method == "HEAD":
                         curl.setopt(pycurl.NOBODY, True)
                     self._setcurltimeouts(curl, timeout)
@@ -463,6 +465,8 @@ class KeepClient(object):
                         '{}: {}'.format(k,v) for k,v in self.put_headers.items()])
                     curl.setopt(pycurl.WRITEFUNCTION, response_body.write)
                     curl.setopt(pycurl.HEADERFUNCTION, self._headerfunction)
+                    if self.insecure:
+                        curl.setopt(pycurl.SSL_VERIFYPEER, 0)
                     self._setcurltimeouts(curl, timeout)
                     try:
                         curl.perform()
@@ -762,6 +766,11 @@ class KeepClient(object):
         if local_store is None:
             local_store = os.environ.get('KEEP_LOCAL_STORE')
 
+        if config.flag_is_true('ARVADOS_API_HOST_INSECURE'):
+            self.insecure = True
+        else:
+            self.insecure = False
+
         self.block_cache = block_cache if block_cache else KeepBlockCache()
         self.timeout = timeout
         self.proxy_timeout = proxy_timeout