ignore certificate errors in python for synthetic canary's

1

I'm trying to run a Cloudwatch > Synthetics Canaries (using Python 3.8) and getting this error.
'<' not supported between instances of 'str' and 'int'

It strongly appears to be because the certificate being self signed. It would be nice if AWS fixed this on their end (adding support for self signed), but until that happens is there anyway in the aws webdriver to ignore certificate errors?

Runtime version syn-python-selenium-1.0 (Python 3.8, Selenium 3.141.0, Chromium 83.0.4103.0)

This is the canary script provided by AWS.

from aws_synthetics.selenium import synthetics_webdriver as syn_webdriver
from aws_synthetics.common import synthetics_logger as logger

def main():
    url = "xyz"

    # Set screenshot option
    takeScreenshot = False

    browser = syn_webdriver.Chrome()
    browser.get(url)

    if takeScreenshot:
        browser.save_screenshot("loaded.png")

    response_code = syn_webdriver.get_http_response(url)
    if not response_code or response_code < 200 or response_code > 299:
        raise Exception("Failed to load page!")
    logger.info("Canary successfully executed")

def handler(event, context):
    # user defined log statements using synthetics_logger
    logger.info("Selenium Python heartbeat canary")
    return main()

  • Have you verified this hypothesis by changing the URL to a different HTTPS url?

  • In fact I did, originally the self signed cert url errored, while a 3rd part signed cert worked. But it's possible user-3302110 was right and I'll try some other things.

posta 2 anni fa1710 visualizzazioni
2 Risposte
2

The syn-python-selenium-1.0 runtime version by default launches browser with the --ignore-certificate-errors option set. The reason for the error might be a different error. It might help to log the response prior to the "if not response_code or response_code < 200 or response_code > 299" check

AWS
con risposta 2 anni fa
  • Perhaps your right, an AWS rep said it was due to the self signed cert. I'll try something else.

  • So this morning I created a new syn-python-selenium-1.0 canary and I picked a url with a valid 3party signed cert and it worked. Then I created a 2nd canary, with the same runtime with a self-signed cert and it failed. I have also tried to log the "response_code" but it says it's not set. And I'm presuming it's not set because it can't get past the cert to get a response code. User-3302110, how can you be certain that it launches with --ignore-certificate-errors? Thank you

  • ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)> ERROR: Canary execution exception. Traceback (most recent call last):
    File "/var/task/index.py", line 76, in handle_canary
    response = customer_canary.handler(event, context)
    File "/opt/python/pageLoadBlueprint.py", line 26, in handler
    return main()
    File "/opt/python/pageLoadBlueprint.py", line 19, in main
    if not response_code or response_code < 200 or response_code > 299: TypeError: '<' not supported between instances of 'str' and 'int'

  • I am currently using syn-python-selenium-1.3 and I am having similar certificate issues as well. I even added the --ignore-certificates-errors argument and still no luck. Any updates or workaround for this issue yet?

1

What about 1.3? Does it also use --ignore-certificate-errors? I'm getting this error:

ERROR: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)>

I tried to use

from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--ignore-certificate-errors')
browser = syn_webdriver.Chrome(chrome_options=options)

but I'm still getting the error above.

DenisBY
con risposta 2 anni fa
  • I am getting the same error were you able to find a possible solution by any chance?

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande