Automating the page "The site's security certificate is not trusted!" in Google Chrome

Last edited on

When using an HTTPS URL of a server with an invalid security certificate Google Chrome shows this error message:

The site's security certificate is not trusted!

You attempted to reach, but the server presented a certificate issued by an entity that is not trusted by your computer's operating system. This may mean that the server has generated its own security credentials, which Chrome cannot rely on for identity information, or an attacker may be trying to intercept your communications.

You should not proceed, especially if you have never seen this warning before for this site.

Proceed anyway | Back to safety

Help me understand

However it works to press the Tab key until the entry Proceed anyway is highlighted. After that pressing the Return key opens the URL anyway.

We can use this behavior to get past this page in Google Chrome by sending the same key presses via nativeType() to the browser, but we have to load another "dummy" URL first:

def main():
    test.log("First load a dummy URL...")

    test.log("Load the real URL through evalJS()...")
    evalJS('window.location = ""')

    test.log("Get input focus into button to accept...(browser must be active application!)")

    test.log("Press Accept button...(browser must be active application!)")

Note the snooze() statements that are inserted to wait for Google Chrome to have loaded the web site and to give it time to process the key presses.