From 2d3cceda465a61e53fcdea4c98a07b3fd998a0cc Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sat, 16 Nov 2019 12:22:19 +0000 Subject: [PATCH] ResourceAccessor: Warn and retry without validation on certificate failure --- volatility/framework/layers/resources.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/volatility/framework/layers/resources.py b/volatility/framework/layers/resources.py index 27655c8a8..47149b880 100644 --- a/volatility/framework/layers/resources.py +++ b/volatility/framework/layers/resources.py @@ -14,6 +14,7 @@ import urllib.parse import urllib.request import zipfile from typing import Optional, Any +from urllib import error from volatility import framework from volatility.framework import constants @@ -65,7 +66,22 @@ class ResourceAccessor(object): """ urllib.request.install_opener(urllib.request.build_opener(*self._handlers)) - with contextlib.closing(urllib.request.urlopen(url, context = self._context)) as fp: + try: + fp = urllib.request.urlopen(url, context = self._context) + except error.URLError as excp: + if excp.args: + if isinstance(excp.args[0], ssl.SSLCertVerificationError): + vollog.warning("SSL certificate verification failed: attempting UNVERIFIED retrieval") + non_verifying_ctx = ssl.SSLContext() + non_verifying_ctx.check_hostname = False + non_verifying_ctx.verify_mode = ssl.CERT_NONE + fp = urllib.request.urlopen(url, context = non_verifying_ctx) + else: + raise excp + else: + raise excp + + with contextlib.closing(fp) as fp: # Cache the file locally parsed_url = urllib.parse.urlparse(url)