jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API
GNU Lesser General Public License v2.1
644 stars 304 forks source link

Adds parameter for custom ssl contexts #50

Closed arnuschky closed 5 years ago

arnuschky commented 9 years ago

This change allows to add custom SSL contexts as a parameter to AuthServiceProxy.

Example 1: select a specific protocol version. For example, btcd does not accept anything below TLS 1.2, and auto-selection is broken on many old distributions/versions. See also #35. Note: TLS 1.2 needs python >= 2.7.9

import ssl;
sslContext = ssl.create_default_context()
sslContext.protocol = ssl.PROTOCOL_TLSv1_2
rpc = AuthServiceProxy("https://username:password@hostname:port", ssl_context=sslContext);

Example 2: don't verify ssl certificates Note: ONLY debug usage, insecure!

import ssl;
sslContext = ssl.create_default_context()
sslContext.check_hostname = False
sslContext.verify_mode = ssl.CERT_NONE
rpc = AuthServiceProxy("https://username:password@hostname:port", ssl_context=sslContext);
justinmoon commented 5 years ago

I just tested this. It works. Without this change RPC with a btcd node didn't work. With this change it did work.

Ship it!