Hi Team,
I am trying to skip certificate check in treq request. But i dont find any parameter in treq library which skips the ssl check. Could you please help here.
Best Regards,
Nigal Thomas
Hi Team,
I am trying to skip certificate check in treq request. But i dont find any parameter in treq library which skips the ssl check. Could you please help here.
Best Regards,
Nigal Thomas
I do not know treq specifically.
But usually you configure this using an SSL Context in most libraies.
Copilot said that you can do that by using an SSLContext
with verify_mode
set to CERT_NONE
.
It gave this example:
import treq
import ssl
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
@inlineCallbacks
def fetch():
contextFactory = ssl.create_default_context()
contextFactory.check_hostname = False
contextFactory.verify_mode = ssl.CERT_NONE
response = yield treq.get('https://example.com', contextFactory=contextFactory)
content = yield response.text()
print(content)
reactor.callWhenRunning(fetch)
reactor.run()
As always, you need to check whether the answer it gives is correct.
Hi,
Thanks for the support. Tried the below snippet but it throws “Got an builtins.TypeError: saying request() got an unexpected argument ‘contextFactory’”
Is treq.get(...)
passing it on to requests.get(...)
?
The docs here:
Advanced Usage — Requests 2.32.3 documentation
are about requests.get(...)
and SSL, which suggests to me that you could try replacing the offending line with:
response = yield treq.get('https://example.com', verify=False)
Good luck!