Fix CA certificate handling

If --os-cacert was passed to the cli the following error was
triggered: "cafile must be None or a byte string". This is
because 'load_verify_locations' requires a byte string to
be passed in.

We fix this by explicitly converting the argument to a byte
string.

We do this in 'VerifiedHTTPSConnection' rather than sooner, eg
during arg handling, as it will no longer be required should we
move to a different http library (eg requests).

Fixes bug 1301849.

Change-Id: I9014f5d040cae9f0b6f03d8f13de8419597560cb
This commit is contained in:
Stuart McLaren
2014-04-03 09:58:31 +00:00
parent dbefc1a3b1
commit 6626f38cda
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -378,7 +378,7 @@ class VerifiedHTTPSConnection(HTTPSConnection):
self.timeout = timeout
self.insecure = insecure
self.ssl_compression = ssl_compression
self.cacert = cacert
self.cacert = None if cacert is None else str(cacert)
self.setcontext()
# ssl exceptions are reported in various form in Python 3
# so to be compatible, we report the same kind as under