From 0a5d1bbda34c252dd80edf0f85d68909de3a9196 Mon Sep 17 00:00:00 2001
From: lrossett <lrossett@redhat.com>
Date: Dec 11 2020 13:28:02 +0000
Subject: [PATCH 1/3] set serverca opts


---

diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py
index fccad88..d0b9342 100644
--- a/www/kojiweb/index.py
+++ b/www/kojiweb/index.py
@@ -172,8 +172,12 @@ def _assertLogin(environ):
 
 
 def _getServer(environ):
-    opts = environ['koji.options']
-    session = koji.ClientSession(opts['KojiHubURL'])
+    koji_opts = environ['koji.options']
+    opts = {
+        'serverca': koji_opts.get('KojiHubCA', '')
+    }
+    
+    session = koji.ClientSession(koji_opts['KojiHubURL'], opts=opts)
 
     environ['koji.currentLogin'] = _getUserCookie(environ)
     if environ['koji.currentLogin']:

From d02290cb7a97f49557242f44fecfc52f1f91f820 Mon Sep 17 00:00:00 2001
From: lrossett <lrossett@redhat.com>
Date: Dec 11 2020 13:28:05 +0000
Subject: [PATCH 2/3] requests exception


---

diff --git a/koji/__init__.py b/koji/__init__.py
index 2245242..4fc0ec5 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -58,6 +58,7 @@ import six.moves.http_client
 import six.moves.urllib
 from requests.adapters import HTTPAdapter
 from requests.packages.urllib3.util.retry import Retry
+from requests.exceptions import RequestException
 from six.moves import range, zip
 
 from koji.xmlrpcplus import Fault, dumps, getparser, loads, xmlrpc_client
@@ -2771,6 +2772,14 @@ class ClientSession(object):
                     # (depending on the python version, these may or may not be subclasses of
                     # Exception)
                     raise
+                except RequestException as e:
+                    _err_res = e.response
+                    _err_req = e.request
+                    if _err:
+                        self.logger.error('Response error: %s::%s::%s' % (_err_res.status_code, _err_res.text, str(_err_res)))
+                    else:
+                        self.logger.error('Request error: %s::%s::%s' % (_err_req.method, _err_req.url, str(_err_req)))
+                    raise
                 except Exception as e:
                     tb_str = ''.join(traceback.format_exception(*sys.exc_info()))
                     self.new_session()

From 79bb5dd0a862ce8f9fab609b056983b93cafe939 Mon Sep 17 00:00:00 2001
From: lrossett <lrossett@redhat.com>
Date: Dec 11 2020 13:28:09 +0000
Subject: [PATCH 3/3] flake8 fixes


---

diff --git a/koji/__init__.py b/koji/__init__.py
index 4fc0ec5..84665ba 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -2775,10 +2775,12 @@ class ClientSession(object):
                 except RequestException as e:
                     _err_res = e.response
                     _err_req = e.request
-                    if _err:
-                        self.logger.error('Response error: %s::%s::%s' % (_err_res.status_code, _err_res.text, str(_err_res)))
+                    if _err_res:
+                        _values = (_err_res.status_code, _err_res.text, str(_err_res))
+                        self.logger.error('Response error: %s::%s::%s' % _values)
                     else:
-                        self.logger.error('Request error: %s::%s::%s' % (_err_req.method, _err_req.url, str(_err_req)))
+                        _values = (_err_req.method, _err_req.url, str(_err_req))
+                        self.logger.error('Request error: %s::%s::%s' % _values)
                     raise
                 except Exception as e:
                     tb_str = ''.join(traceback.format_exception(*sys.exc_info()))
diff --git a/vm/kojikamid.py b/vm/kojikamid.py
index e7bf1b9..02a00b6 100755
--- a/vm/kojikamid.py
+++ b/vm/kojikamid.py
@@ -40,7 +40,6 @@ import time
 import traceback
 import zipfile
 from optparse import OptionParser
-
 import xmlrpc.client
 # urllib is required by the SCM class which is substituted into this file
 # do not remove the import below
diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py
index d0b9342..efb403d 100644
--- a/www/kojiweb/index.py
+++ b/www/kojiweb/index.py
@@ -176,7 +176,7 @@ def _getServer(environ):
     opts = {
         'serverca': koji_opts.get('KojiHubCA', '')
     }
-    
+
     session = koji.ClientSession(koji_opts['KojiHubURL'], opts=opts)
 
     environ['koji.currentLogin'] = _getUserCookie(environ)

