<div dir="ltr"><div dir="ltr"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 19, 2018 at 7:24 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">For real imageio servers the destination will always be https.  This<br>
change has no effect there.<br>
<br>
However when testing we want to use an http server for simplicity.  As<br>
there is no cafile in this case the call to<br>
ssl.create_default_context().load_verify_locations(cafile=...) will fail.<br>
---<br>
 v2v/rhv-upload-plugin.py | 7 +++++--<br>
 1 file changed, 5 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py<br>
index 5cd6d5cab..6e35b5057 100644<br>
--- a/v2v/rhv-upload-plugin.py<br>
+++ b/v2v/rhv-upload-plugin.py<br>
@@ -207,8 +207,11 @@ def open(readonly):<br>
     else:<br>
         destination_url = urlparse(transfer.proxy_url)<br>
<br>
-    context = ssl.create_default_context()<br>
-    context.load_verify_locations(cafile = params['rhv_cafile'])<br></blockquote><div><br></div><div>This line was never needed. In imageio client we use:</div><div><br></div><div><div>    context = ssl.create_default_context(</div><div>        purpose=ssl.Purpose.SERVER_AUTH, cafile=cafile)</div><div><br></div><div>    if not secure:</div><div>        context.check_hostname = False</div><div>        context.verify_mode = ssl.CERT_NONE</div></div><div><br></div><div>See <a href="https://github.com/oVirt/ovirt-imageio/blob/356d224f1124deb3d63125b1f3b3e583839bcbd9/common/ovirt_imageio_common/client.py#L52">https://github.com/oVirt/ovirt-imageio/blob/356d224f1124deb3d63125b1f3b3e583839bcbd9/common/ovirt_imageio_common/client.py#L52</a></div><div><br></div><div>So we can replace this with</div><div><br></div><div>    context = ssl.create_default_context(cafile = params.get('rhv_cafile'))</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+    if destination_url.scheme == "https":<br>
+        context = ssl.create_default_context()<br>
+        context.load_verify_locations(cafile = params['rhv_cafile'])<br>
+    else:<br>
+        context = None<br></blockquote><div><br></div><div>This will create a default context inside HTTPSConnection.__init__, which will try to </div><div>verify the server certificate and hostname and may fail if the certificates are not set</div><div>up properly in the tests.</div><div><br></div><div>Nir</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
     http = HTTPSConnection(<br>
         destination_url.hostname,<br>
-- <br>
2.19.0.rc0<br>
<br>
_______________________________________________<br>
Libguestfs mailing list<br>
<a href="mailto:Libguestfs@redhat.com" target="_blank">Libguestfs@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libguestfs" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/libguestfs</a><br>
</blockquote></div></div></div></div>