i'm trying to send post request to daemon which is SSL applied. i want to pass the SSL verification and encrypt with SSL at the same time and here is what i found :
but i can't find simillar one in twisted agent.request.
Control TLS behavior using the contextFactory
argument to twisted.web.client.Agent.__init__
.
The value for this parameter should provide twisted.web.iweb.IPolicyForHTTPS
. This interface defines a method (creatorForNetloc
) which is used to set up the TLS connection.
Twisted includes one distinct implementation of this interface which implements a policy like that used by most modern web browsers.
You can create your own implementation which does something else, such as disregard certificate validation errors - even on a per-host basis - or does things like adds custom trust roots so you can still verify the certificate without requiring it be issued by a certificate authority.
twisted.internet.ssl.optionsForClientTLS
is useful for implementing some behaviors in creatorForNetloc
- however it does not support completely ignoring all validation errors. For that, you might benefit from using twisted.internet.ssl.ClientTLSOptions
which accepts an arbitrary OpenSSL.SSL.Context
instance that controls most of its behavior.
OpenSSL.SSL.Context
lets you control approximately every feature of OpenSSL that it is possible to control when using TLS with Twisted - including ignoring validation errors, if that's what you really need.
The most straightforward way to do that is to use Context.set_verify
with a suitably defined function.