Commit f2ed2e68 authored by Lucas Carvalho's avatar Lucas Carvalho

NetworkcacheClient must use libconnection

To download contents in a correct way, it must use the
libnetworkcache.
parent 00e24d33
...@@ -22,6 +22,7 @@ import tempfile ...@@ -22,6 +22,7 @@ import tempfile
import urllib import urllib
import urllib2 import urllib2
import M2Crypto import M2Crypto
import slapos.libconnection
from slapos.libnetworkcacheutils import parseUrl from slapos.libnetworkcacheutils import parseUrl
...@@ -202,7 +203,7 @@ class NetworkcacheClient(object): ...@@ -202,7 +203,7 @@ class NetworkcacheClient(object):
return True return True
for certificate_url in self.signature_certificate_url_list: for certificate_url in self.signature_certificate_url_list:
file_descriptor = self._fetchCertificateFileFromUrl(certificate_url) file_descriptor = slapos.libconnection.download(certification_file_url)
try: try:
file_name = file_descriptor.name file_name = file_descriptor.name
if self._verifySignatureCertificate(signature_string, file_name): if self._verifySignatureCertificate(signature_string, file_name):
...@@ -221,14 +222,6 @@ class NetworkcacheClient(object): ...@@ -221,14 +222,6 @@ class NetworkcacheClient(object):
VerifyEVP.verify_update('') VerifyEVP.verify_update('')
return VerifyEVP.verify_final(signature_string.decode('base64')) return VerifyEVP.verify_final(signature_string.decode('base64'))
def _fetchCertificateFileFromUrl(self, certification_file_url):
""" Download the certification files from the url. """
file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(certification_file_url, file_descriptor.name)
file_descriptor.seek(0)
return file_descriptor
class DirectoryNotFound(Exception): class DirectoryNotFound(Exception):
pass pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment