misc: make http_request intercept SSL certificate errors (#14527)

This commit is contained in:
Frédéric Péters 2017-01-24 11:36:11 +01:00
parent 5cf733fda2
commit f03476ab94
1 changed files with 4 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import time
import httplib
import urllib
import socket
import ssl
import base64
import json
import subprocess
@ -287,6 +288,9 @@ def _http_request(url, method='GET', body=None, headers={}, timeout=None):
except socket.error, err:
conn.close()
raise ConnectionError('error while fetching the page : %s' % err)
except ssl.CertificateError, err:
conn.close()
raise ConnectionError('certificate error when connecting (%s)' % err)
else:
data = response.read()
status = response.status