[Libguestfs] [PATCH 2/3] v2v: -o rhv-upload: Only set SSL context for https connections.
Richard W.M. Jones
rjones at redhat.com
Wed Sep 19 16:23:56 UTC 2018
For real imageio servers the destination will always be https. This
change has no effect there.
However when testing we want to use an http server for simplicity. As
there is no cafile in this case the call to
ssl.create_default_context().load_verify_locations(cafile=...) will fail.
---
v2v/rhv-upload-plugin.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
index 5cd6d5cab..6e35b5057 100644
--- a/v2v/rhv-upload-plugin.py
+++ b/v2v/rhv-upload-plugin.py
@@ -207,8 +207,11 @@ def open(readonly):
else:
destination_url = urlparse(transfer.proxy_url)
- context = ssl.create_default_context()
- context.load_verify_locations(cafile = params['rhv_cafile'])
+ if destination_url.scheme == "https":
+ context = ssl.create_default_context()
+ context.load_verify_locations(cafile = params['rhv_cafile'])
+ else:
+ context = None
http = HTTPSConnection(
destination_url.hostname,
--
2.19.0.rc0
More information about the Libguestfs
mailing list