diff --git a/ofxclient/client.py b/ofxclient/client.py index 036dfaf..24ffb97 100644 --- a/ofxclient/client.py +++ b/ofxclient/client.py @@ -15,6 +15,7 @@ # python 2 from urllib import splittype, splithost import uuid +import ssl DEFAULT_APP_ID = 'QWIN' DEFAULT_APP_VERSION = '2500' @@ -154,7 +155,15 @@ def _do_post(self, query, extra_headers=[]): logging.debug('posting data to %s' % i.url) garbage, path = splittype(i.url) host, selector = splithost(path) - h = HTTPSConnection(host, timeout=60) + try: + h = HTTPSConnection(host, timeout=60) + h.connect() + except ssl.SSLError as ex: + if (ex.reason == "UNSUPPORTED_PROTOCOL"): + h = HTTPSConnection(host, timeout=60, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1)) + h.connect() + else: + raise # Discover requires a particular ordering of headers, so send the # request step by step. h.putrequest('POST', selector, skip_host=True,