-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for TLS authentication when using FastHttpUser
#2066
Comments
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Hey @jumaffre, I know this is not straightforward but you can try something like that (worked for me): import gevent
from locust import task
from locust.contrib.fasthttp import FastHttpUser
def _create_default_context():
context = gevent.ssl.create_default_context()
context.check_hostname = True
context.verify_mode = gevent.ssl.CERT_REQUIRED
context.load_cert_chain(certfile="yourpempath", keyfile="yourkeypath")
context.load_verify_locations(cafile="yourcapath")
return context
class ApiLocust(FastHttpUser):
def __init__(self, environment):
super().__init__(environment=environment)
self.client.client.clientpool.client_args['ssl_context_factory'] = _create_default_context
@task()
def submit(self):
self.client.get('endpoint') |
@renato-farias Thank you for the pointer. I'll give it a try shortly. |
This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself! |
Is your feature request related to a problem? Please describe.
The
FastHTTPUser
does not support TLS client authentication (using a private key/certificate).Describe the solution you'd like
It should be possible to set client TLS session authentication when using the
FastHttpUser
. Ideally, it should be possible to access the underlying SSL context object, or supply it when creating the user.Describe alternatives you've considered
HttpUser
supports this feature but is obviously slower.Additional context
With
HttpUser
, when targeting a HTTPS server that makes use of TLS client authentication, the following works OK, but does not work (401
response code) when switching toFastHttpUser
:The text was updated successfully, but these errors were encountered: