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 www.froglogic.com, 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...")
    loadUrl("http://www.microsoft.com/")
    waitForObject("DOCUMENT.HTML1.BODY1")
    snooze(3)

    test.log("Load the real URL through evalJS()...")
    evalJS('window.location = "https://www.argandenergy.com"')
    snooze(3)

    test.log("Get input focus into button to accept...(browser must be active application!)")
    nativeType("<Tab>")
    snooze(1)

    test.log("Press Accept button...(browser must be active application!)")
    nativeType("<Return>")
    snooze(1)
test.py

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.