From 6180bf13624b0f1d3a5bd89de685dc901b2b0405 Mon Sep 17 00:00:00 2001 From: Peter Todd Date: Tue, 19 Apr 2016 02:32:25 -0400 Subject: [PATCH] Remove RPC over SSL support Removed in Bitcoin Core v0.12.0 --- bitcoin/rpc.py | 42 +++++------------------------------------- release-notes.md | 4 ++++ 2 files changed, 9 insertions(+), 37 deletions(-) diff --git a/bitcoin/rpc.py b/bitcoin/rpc.py index 022ca343..93958e28 100644 --- a/bitcoin/rpc.py +++ b/bitcoin/rpc.py @@ -109,51 +109,24 @@ def __init__(self, if service_port is None: service_port = bitcoin.params.RPC_PORT conf['rpcport'] = int(conf.get('rpcport', service_port)) - conf['rpcssl'] = conf.get('rpcssl', '0') conf['rpchost'] = conf.get('rpcconnect', 'localhost') - if conf['rpcssl'].lower() in ('0', 'false'): - conf['rpcssl'] = False - elif conf['rpcssl'].lower() in ('1', 'true'): - conf['rpcssl'] = True - else: - raise ValueError('Unknown rpcssl value %r' % conf['rpcssl']) - - if conf['rpcssl'] and 'rpcsslcertificatechainfile' in conf and 'rpcsslprivatekeyfile' in conf: - self.__ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) - if os.path.exists(conf['rpcsslcertificatechainfile']): - certificate = conf['rpcsslcertificatechainfile'] - elif os.path.exists(os.path.join(os.path.dirname(btc_conf_file), conf['rpcsslcertificatechainfile'])): - certificate = os.path.join(os.path.dirname(btc_conf_file), conf['rpcsslcertificatechainfile']) - else: - raise ValueError('The value of rpcsslcertificatechainfile is not correctly specified in the configuration file: %s' % btc_conf_file) - if os.path.exists(conf['rpcsslprivatekeyfile']): - private_key = conf['rpcsslprivatekeyfile'] - elif os.path.exists(os.path.join(os.path.dirname(btc_conf_file), conf['rpcsslprivatekeyfile'])): - private_key = os.path.join(os.path.dirname(btc_conf_file), conf['rpcsslprivatekeyfile']) - else: - raise ValueError('The value of rpcsslprivatekeyfile is not correctly specified in the configuration file: %s' % btc_conf_file) - self.__ssl_context.load_cert_chain(certificate, private_key) - if 'rpcpassword' not in conf: raise ValueError('The value of rpcpassword not specified in the configuration file: %s' % btc_conf_file) service_url = ('%s://%s:%s@%s:%d' % - ('https' if conf['rpcssl'] else 'http', + ('http', conf['rpcuser'], conf['rpcpassword'], conf['rpchost'], conf['rpcport'])) self.__service_url = service_url self.__url = urlparse.urlparse(service_url) - if self.__url.scheme not in ('https', 'http'): + if self.__url.scheme not in ('http',): raise ValueError('Unsupported URL scheme %r' % self.__url.scheme) if self.__url.port is None: - if self.__url.scheme == 'https': - port = httplib.HTTPS_PORT - else: - port = httplib.HTTP_PORT + port = httplib.HTTP_PORT else: port = self.__url.port self.__id_count = 0 @@ -161,13 +134,8 @@ def __init__(self, authpair = authpair.encode('utf8') self.__auth_header = b"Basic " + base64.b64encode(authpair) - if self.__url.scheme == 'https': - self.__conn = httplib.HTTPSConnection(self.__url.hostname, port=port, - context=self.__ssl_context, - timeout=timeout) - else: - self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port, - timeout=timeout) + self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port, + timeout=timeout) def _call(self, service_name, *args): diff --git a/release-notes.md b/release-notes.md index dc353f18..760b1a00 100644 --- a/release-notes.md +++ b/release-notes.md @@ -6,6 +6,10 @@ v0.6.0-SNAPSHOT (not yet released!) Breaking API changes: +* RPC over SSL support removed to match Bitcoin Core's removal of RPC SSL + support in v0.12.0 If you need this, use an alternative such as a stunnel or + a SSH tunnel. + * Removed SCRIPT_VERIFY constants ``bitcoin.core.script``, leaving just the constants in ``bitcoin.core.scripteval``; being singletons the redundant constants were broken anyway.