Locust: SSL errors when testing certain HTTPS sites

Created on 13 May 2016  ·  5Comments  ·  Source: locustio/locust

I'm getting SSL errors sometimes when using certain HTTPS sites using locust:

In [26]: u
Out[26]: <locust.core.HttpLocust at 0x104f94cd0>

In [27]: u.host
Out[27]: 'https://www.dodopal.com'

In [28]: res = u.client.get('/'); res.__dict__
Out[28]: 
{'_content': None,
 '_content_consumed': True,
 'cookies': <RequestsCookieJar[]>,
 'elapsed': datetime.timedelta(0),
 'encoding': None,
 'error': requests.exceptions.SSLError(requests.packages.urllib3.exceptions.SSLError(ssl.SSLError(1,
                                                                                         u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)'))),
 'headers': {},
 'history': [],
 'raw': None,
 'reason': None,
 'request': <PreparedRequest [GET]>,
 'status_code': 0,
 'url': None}

Other sites seem to be fine:

In [35]: u.host = 'https://www.eff.org'

In [36]: u.client.get('/')
Out[36]: <Response [200]>

Most helpful comment

How to get rid from “SSL: CERTIFICATE_VERIFY_FAILED” Error

On Windows, Python does not look at the system certificate, it uses its own located at ?\lib\site-packages\certifi\cacert.pem.

The solution to your problem:

  1. download the domain validation certificate as *.crt or *pem file
  2. open the file in editor and copy it's content to clipboard
  3. find your cacert.pem location: from requests.utils import DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH)
  4. edit the cacert.pem file and paste your domain validation certificate at the end of the file.
  5. Save the file and enjoy requests!

All 5 comments

This could be related to this issue, but the suggested solution is not practical because it means modifying requests code inside locust source.

This is the hackish workaround I'm using. I put this in my task set definition, so it'll run when the TaskSet is loaded.

import requests
requests.packages.urllib3.disable_warnings() # disable SSL warnings

Perhaps it can be added to the code base that spawns the threads.

How to get rid from “SSL: CERTIFICATE_VERIFY_FAILED” Error

On Windows, Python does not look at the system certificate, it uses its own located at ?\lib\site-packages\certifi\cacert.pem.

The solution to your problem:

  1. download the domain validation certificate as *.crt or *pem file
  2. open the file in editor and copy it's content to clipboard
  3. find your cacert.pem location: from requests.utils import DEFAULT_CA_BUNDLE_PATH; print(DEFAULT_CA_BUNDLE_PATH)
  4. edit the cacert.pem file and paste your domain validation certificate at the end of the file.
  5. Save the file and enjoy requests!

possible duplicate of #300

I'm not sure what this means: "paste your domain validation certificate at the end of the file". When I open my domain.crt up in notepad it's all encrypted.
0‚0‚ ]º–l
á“GèaÜ.
That's what I'd be adding to the locust pem file. Can I get some clarification on this?

Was this page helpful?
0 / 5 - 0 ratings