diff --git a/certbot-ci/certbot_integration_tests/utils/acme_server.py b/certbot-ci/certbot_integration_tests/utils/acme_server.py index 718a8fcb1..db3a2d1c4 100755 --- a/certbot-ci/certbot_integration_tests/utils/acme_server.py +++ b/certbot-ci/certbot_integration_tests/utils/acme_server.py @@ -142,7 +142,7 @@ def _prepare_acme_server(workspace, acme_type, acme_xdist): # Also disable strict mode for now, since Pebble v2.1.0 added specs in # strict mode for which Certbot is not compliant for now. - # See https://github.com/certbot/certbot/pull/7175 + # See https:/l/github.com/certbot/certbot/pull/7175 # TODO: Add back -strict mode once Certbot is compliant with Pebble v2.1.0+ config['services']['pebble']['command'] = config['services']['pebble']['command']\ .replace('-strict', '') @@ -150,14 +150,16 @@ def _prepare_acme_server(workspace, acme_type, acme_xdist): with open(os.path.join(instance_path, 'docker-compose.yml'), 'w') as file_handler: file_handler.write(yaml.dump(config)) - with open(os.path.join(instance_path, 'test', 'pebble-config.json'), 'r') as file_handler: - config = yaml.load(file_handler.read()) + with open(os.path.join(instance_path, 'test', 'config', 'pebble-config.json'), 'r') as file_handler: + config = json.loads(file_handler.read()) # Setup the OCSP Responder URL for Pebble to local mock - config['ocspResponderURL'] = 'http://127.0.0.1:{0}'.format(MOCK_OCSP_SERVER_PORT) + config['pebble']['ocspResponderURL'] = 'http://127.0.0.1:{0}'.format(MOCK_OCSP_SERVER_PORT) - with open(os.path.join(instance_path, 'test', 'pebble-config.json'), 'w') as file_handler: - file_handler.write(yaml.dump(config)) + print(json.dumps(config)) + + with open(os.path.join(instance_path, 'test', 'config', 'pebble-config.json'), 'w') as file_handler: + file_handler.write(json.dumps(config)) # Launch the ACME CA server. _launch_command(['docker-compose', 'up', '--force-recreate', '-d'], cwd=instance_path) diff --git a/certbot-ci/certbot_integration_tests/utils/misc.py b/certbot-ci/certbot_integration_tests/utils/misc.py index cfdd53d4a..ddb04f7ec 100644 --- a/certbot-ci/certbot_integration_tests/utils/misc.py +++ b/certbot-ci/certbot_integration_tests/utils/misc.py @@ -27,14 +27,6 @@ from six.moves import socketserver, SimpleHTTPServer from certbot_integration_tests.utils import ocsp_server from certbot_integration_tests.utils.constants import MOCK_OCSP_SERVER_PORT -try: - import urllib3 - urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) -except ImportError: - # Handle old versions of request with vendorized urllib3 - from requests.packages.urllib3.exceptions import InsecureRequestWarning - requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - RSA_KEY_TYPE = 'rsa' ECDSA_KEY_TYPE = 'ecdsa' @@ -49,6 +41,7 @@ def check_until_timeout(url): for _ in range(0, 150): time.sleep(1) try: + _ignore_https_warnings() if requests.get(url, verify=False).status_code == 200: return except requests.exceptions.ConnectionError: @@ -299,8 +292,10 @@ def mock_ocsp_server(directory_url, workspace): key_path = os.path.join(workspace, 'ocsp_key.pem') cert_path = os.path.join(workspace, 'ocsp_cert.pem') with open(key_path, 'w') as file_h: + _ignore_https_warnings() file_h.write(requests.get(root_url + '/intermediate-key', verify=False).content) with open(cert_path, 'w') as file_h: + _ignore_https_warnings() file_h.write(requests.get(root_url + '/intermediate', verify=False).content) environ = os.environ.copy() @@ -310,3 +305,13 @@ def mock_ocsp_server(directory_url, workspace): process = subprocess.Popen([sys.executable, ocsp_server.__file__], env=environ) return process, 'http://127.0.0.1:{0}'.format(MOCK_OCSP_SERVER_PORT) + + +def _ignore_https_warnings(): + try: + import urllib3 + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + except ImportError: + # Handle old versions of request with vendorized urllib3 + from requests.packages.urllib3.exceptions import InsecureRequestWarning + requests.packages.urllib3.disable_warnings(InsecureRequestWarning)