Author

Topic: [Solved] Blockchain.info SSLError (Read 1596 times)

rex
newbie
Activity: 52
Merit: 0
March 01, 2013, 03:14:02 AM
#3
OK, I find the solution here:
http://askubuntu.com/questions/116020/python-https-requests-urllib2-to-some-sites-fail-on-ubuntu-12-04-without-proxy

it works like a charm.

For those who has the same problem, here's my code snippet:

Code:
        host = "blockchain.info"
        url_path = "/merchant/%s/new_address?password=%s&second_password=%s&label=%s" % (guid, main_pwd, snd_pwd, label)

        conn = httplib.HTTPSConnection(host)
        sock = socket.create_connection((conn.host, conn.port), conn.timeout, conn.source_address)
        conn.sock = ssl.wrap_socket(sock, conn.key_file, conn.cert_file, ssl_version=ssl.PROTOCOL_TLSv1)
        conn.request('GET', url_path)
        rsp = conn.getresponse()
        assert rsp.status == 200
        address = json.loads(rsp.read())['address']
rex
newbie
Activity: 52
Merit: 0
March 01, 2013, 02:44:44 AM
#2
Somehow I figured out that blockchain.info uses TLS 1.0. I need to find a way to force my program to use tls1.0. Hope it will work
rex
newbie
Activity: 52
Merit: 0
March 01, 2013, 01:56:19 AM
#1
I'm trying to generate an new address by this:
https://blockchain.info/merchant/$guid/new_address?password=$main_password&second_password=$second_password&label=$label

However, I always get the following error:
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

my Python codes are like this:
Code:
import requests
import json

guid = "XXXX"
url = "https://blockchain.info/merchant/%s/new_address" % guid
params = dict(
     password="main_pwd",
     second_password="snd_pwd",
     label="label"
)
resp = requests.get(url, params=params)
data = json.load(resp)

the exception raises when executing this line:
Code:
resp = requests.get(url, params=params)

Any help would be very much appreciated!!
Jump to: