Skip to content
  • Richard W.M. Jones's avatar
    637fa44a
    curl: Make sslverify=off disable host as well as peer verification. · 637fa44a
    Richard W.M. Jones authored
    The sslverify setting is supposed to turn off all TLS certificate
    checks in libcurl.  However because of the way we use it, it only
    turns off peer certificate authenticity checks
    (CURLOPT_SSL_VERIFYPEER).  This patch makes it also turn off the check
    that the server name in the certificate is the same as the server
    you're connecting to (CURLOPT_SSL_VERIFYHOST).
    
    We can use Google's server at 8.8.8.8 which happens to have a bad TLS
    certificate to demonstrate this:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
    Could not open backing image to determine size.
    
    With this patch applied, qemu-img connects to the server regardless of
    the bad certificate:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: The requested URL returned error: 404 Not Found
    
    (The 404 error is expected because 8.8.8.8 is not actually serving a
    file called "/foo".)
    
    Of course the default (without sslverify=off) remains to always check
    the certificate:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
    Could not open backing image to determine size.
    
    Further information about the two settings is available here:
    
    https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html
    https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
    
    
    
    Signed-off-by: default avatarRichard W.M. Jones <rjones@redhat.com>
    Message-id: 20180914095622.19698-1-rjones@redhat.com
    Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
    637fa44a
    curl: Make sslverify=off disable host as well as peer verification.
    Richard W.M. Jones authored
    The sslverify setting is supposed to turn off all TLS certificate
    checks in libcurl.  However because of the way we use it, it only
    turns off peer certificate authenticity checks
    (CURLOPT_SSL_VERIFYPEER).  This patch makes it also turn off the check
    that the server name in the certificate is the same as the server
    you're connecting to (CURLOPT_SSL_VERIFYHOST).
    
    We can use Google's server at 8.8.8.8 which happens to have a bad TLS
    certificate to demonstrate this:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
    Could not open backing image to determine size.
    
    With this patch applied, qemu-img connects to the server regardless of
    the bad certificate:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.sslverify": "off", "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: The requested URL returned error: 404 Not Found
    
    (The 404 error is expected because 8.8.8.8 is not actually serving a
    file called "/foo".)
    
    Of course the default (without sslverify=off) remains to always check
    the certificate:
    
    $ ./qemu-img create -q -f qcow2 -b 'json: { "file.driver": "https", "file.url": "https://8.8.8.8/foo" }' /var/tmp/file.qcow2
    qemu-img: /var/tmp/file.qcow2: CURL: Error opening file: SSL: no alternative certificate subject name matches target host name '8.8.8.8'
    Could not open backing image to determine size.
    
    Further information about the two settings is available here:
    
    https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html
    https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
    
    
    
    Signed-off-by: default avatarRichard W.M. Jones <rjones@redhat.com>
    Message-id: 20180914095622.19698-1-rjones@redhat.com
    Signed-off-by: default avatarJeff Cody <jcody@redhat.com>
Loading