Disable SSL certificate check Twisted Agents
<p>I am using Twisted (16.3) and Treq (15.1) to make async requests in Python (2.7). </p>

<p>I am having issues with some requests over HTTPS.</p>

<p>Some sites have an invalid certificate and thus when making a request to them, I get this:</p>

<pre><code>twisted.python.failure.Failure OpenSSL.SSL.Error
</code></pre>

<p>I want my client to trust any server, including those without certificates or with self signed certificates.</p>

<p>How can I disable certificate checks on my client?</p>

<p>This is a question essentially identical to mine: <a href="http://stackoverflow.com/questions/34357439/ssl-options-for-twisted-agents">SSL Options for Twisted Agents</a></p>

<p>Thanks!</p>

<p>I've been trying to do this too over the past few days as well. With all the effort I put into circumventing certificate verification, I could've easily just created a pair of keys and been on my merry way :D. I found <a href="https://github.com/twisted/treq/issues/65#issuecomment-249034981" rel="nofollow">this comment</a> on the <code>treq</code> issues board that monkeypatches the issue:</p>

<pre><code>from twisted.internet import _sslverify
_sslverify.platformTrust = lambda : None
</code></pre>

<p>I'm sure there's a convoluted way of doing it "correctly" but it wouldn't be worth the effort in my opinion. I did a patch such that it wouldn't override <code>platformTrust()</code> and I'll try to get it merged but I wouldn't hold my breath. From the tone of some of the bug comments I've seen pertaining to trust roots, ssl, and certificates, I don't think it will get merged. Hope this helps though.</p>

python ssl twisted twisted.web twisted.internet