6

It's my first try at Locus, and unfortunately I don't know Python.

I'm trying a simple request to a valid https server, and I see this error:

SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate

After some research I tried to add this:

import gevent
import geventhttpclient.connectionpool

geventhttpclient.connectionpool.SSLConnectionPool.default_options = {
    "cert_reqs": gevent.ssl.CERT_NONE,
}

or this:

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

I run Locust as instructed:

docker-compose up --scale worker=4

How can I test https sites with Locust?

Thanks in advance

Regards

Saikat
  • 14,222
  • 20
  • 104
  • 125
greg
  • 696
  • 1
  • 9
  • 16

2 Answers2

8

You can do turn the verification off by adding below method:

def on_start(self):
    """ on_start is called when a Locust start before any task is scheduled """
    self.client.verify = False
Saikat
  • 14,222
  • 20
  • 104
  • 125
1

While connecting to a server with a self-signed certificate I had a similar problem. I successfully disabled the certificate verification using the following code (from Locust):

import gevent
from geventhttpclient.url import URL
from geventhttpclient import HTTPClient

def insecure_ssl_context_factory():
    context = gevent.ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = gevent.ssl.CERT_NONE
    return context

url = URL(server)
http = HTTPClient.from_url(url, insecure=True, ssl_context_factory=insecure_ssl_context_factory)
Marduk
  • 982
  • 8
  • 12