Commit 30c06743 authored by slamm's avatar slamm Committed by Commit bot

Install android test certificate authority when host supports SNI

(pyOpenSSL 0.13 or greater).

This relands https://crrev.com/855603002/,
"Roll Web Page Replay to pick-up HTTPS certificate fixes," and
picks-up one additional Web Page Replay change to test for SNI support.

BUG=431686

Review URL: https://codereview.chromium.org/903153002

Cr-Commit-Position: refs/heads/master@{#315333}
parent 5f5ef2b4
...@@ -268,7 +268,7 @@ deps = { ...@@ -268,7 +268,7 @@ deps = {
Var('chromium_git') + '/chromium/tools/deps2git.git' + '@' + 'f04828eb0b5acd3e7ad983c024870f17f17b06d9', Var('chromium_git') + '/chromium/tools/deps2git.git' + '@' + 'f04828eb0b5acd3e7ad983c024870f17f17b06d9',
'src/third_party/webpagereplay': 'src/third_party/webpagereplay':
Var('chromium_git') + '/external/web-page-replay.git' + '@' + '2f7b704b8b567983c040f555d3e46f9766db8e87', Var('chromium_git') + '/external/web-page-replay.git' + '@' + '532b413ff95e8595d5028e0dae75dcf3ba712d2e',
'src/third_party/pywebsocket/src': 'src/third_party/pywebsocket/src':
Var('chromium_git') + '/external/pywebsocket/src.git' + '@' + 'cb349e87ddb30ff8d1fa1a89be39cec901f4a29c', Var('chromium_git') + '/external/pywebsocket/src.git' + '@' + 'cb349e87ddb30ff8d1fa1a89be39cec901f4a29c',
......
...@@ -437,12 +437,19 @@ class AndroidPlatformBackend( ...@@ -437,12 +437,19 @@ class AndroidPlatformBackend(
This allows transparent HTTPS testing with WPR server without need This allows transparent HTTPS testing with WPR server without need
to tweak application network stack. to tweak application network stack.
""" """
# TODO(slamm): Move certificate creation related to webpagereplay.py.
# The only code that needs to be in platform backend is installing the cert.
if certutils.openssl_import_error: if certutils.openssl_import_error:
logging.warning( logging.warning(
'The OpenSSL module is unavailable. ' 'The OpenSSL module is unavailable. '
'Will fallback to ignoring certificate errors.') 'Will fallback to ignoring certificate errors.')
return return
if not certutils.has_sni():
logging.warning(
'Web Page Replay requires SNI support (pyOpenSSL 0.13 or greater) '
'to generate certificates from a test CA. '
'Will fallback to ignoring certificate errors.')
return
try: try:
self._wpr_ca_cert_path = os.path.join(tempfile.mkdtemp(), 'testca.pem') self._wpr_ca_cert_path = os.path.join(tempfile.mkdtemp(), 'testca.pem')
certutils.write_dummy_ca_cert(*certutils.generate_dummy_ca_cert(), certutils.write_dummy_ca_cert(*certutils.generate_dummy_ca_cert(),
...@@ -453,12 +460,13 @@ class AndroidPlatformBackend( ...@@ -453,12 +460,13 @@ class AndroidPlatformBackend(
self._adb.device_serial()) self._adb.device_serial())
self._device_cert_util.install_cert(overwrite_cert=True) self._device_cert_util.install_cert(overwrite_cert=True)
self._is_test_ca_installed = True self._is_test_ca_installed = True
except Exception: except Exception as e:
# Fallback to ignoring certificate errors. # Fallback to ignoring certificate errors.
self.RemoveTestCa() self.RemoveTestCa()
logging.warning('Unable to install test certificate authority on device: ' logging.warning(
'%s. Will fallback to ignoring certificate errors.' 'Unable to install test certificate authority on device: %s. '
% self._adb.device_serial()) 'Will fallback to ignoring certificate errors. Install error: %s',
self._adb.device_serial(), e)
@property @property
def is_test_ca_installed(self): def is_test_ca_installed(self):
......
...@@ -490,6 +490,10 @@ class CertUtilsStub(object): ...@@ -490,6 +490,10 @@ class CertUtilsStub(object):
def generate_dummy_ca_cert(): def generate_dummy_ca_cert():
return '-', '-' return '-', '-'
@staticmethod
def has_sni():
return True
class AdbInstallCertStub(object): class AdbInstallCertStub(object):
class AndroidCertInstaller(object): class AndroidCertInstaller(object):
def __init__(self, device_id, _cert_name, _cert_path): def __init__(self, device_id, _cert_name, _cert_path):
......
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