Closed ilya112358 closed 9 years ago
The server doesn't appear to be responding to the request. The handshake appears to have succeeded, but the server isn't sending anything back. I recommend sending all the headers cURL sent.
Thanks for quick reaction, here is verbose reply from curl:
* Hostname was NOT found in DNS cache
* Trying 84.20.200.150...
* Connected to identitysso.betfair.com (84.20.200.150) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.0 / AES128-SHA
* Server certificate:
* subject: C=GB; ST=London; L=London; O=The Sporting Exchange Limited; OU
=IT Networks; CN=betfair.com
* start date: 2014-10-08 09:06:00 GMT
* expire date: 2016-10-08 09:05:51 GMT
* issuer: C=US; O=HydrantID (Avalanche Cloud Corporation); CN=HydrantID S
SL ICA G2
* SSL certificate verify result: self signed certificate in certificate c
hain (19), continuing anyway.
> POST /api/certlogin HTTP/1.1
> User-Agent: curl/7.38.0
> Host: identitysso.betfair.com
> Accept: */*
> X-Application: TestKey
> Content-Length: 39
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 39 out of 39 bytes
* SSLv3, TLS handshake, Hello request (0):
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS handshake, CERT verify (15):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
< HTTP/1.1 200 OK
< Content-Type: text/plain;charset=ISO-8859-1
< Content-Length: 46
< Date: Tue, 28 Oct 2014 19:14:41 GMT
< Vary: Accept-Encoding
<
{"loginStatus":"INVALID_USERNAME_OR_PASSWORD"}* Connection #0 to host identityss
o.betfair.com left intact
Anything wrong here?
I tried adding the following fields one by one to the headers to no avail.
'Content-Length': '39',
'Accept': '*/*',
'Host': 'identitysso.betfair.com',
'User-Agent': 'curl/7.38.0'
Seriously mind-boggling )
Hmm. What Python version are you using?
As a matter of fact, 2.7.3... Wait a minute! Could it be?.. Installed 2.7.8, works smoothly and efficiently as advertised. Mesa soo stupid! Somehow thought they wouldn't update 2.x versions since they have 3.x already.
Lukasa, thank you so much, man! You literally saved my day!
My pleasure, glad I could help!
I'm having exactly the same issue with Python 2.7.11 (Anaconda 2.4.0), Requests 2.9.0 on 64-bit Windows 7. Post request with certificate attached hangs. If I remove the certificate from requests.post call - then I receive 500 error from the server as expected.
You say "post request with the certificate attached": what exactly does that mean? What specifically are you doing?
I'm trying to submit a SOAP request. By "certificate attached" I mean "cert" parameter set in a requests.post call
headers = {
'Accept-Encoding': 'gzip,deflate',
'Content-Type': 'application/soap+xml;charset=UTF-8',
'User-Agent': 'Apache-HttpClient/4.1.1 (java 1.5)',
}
response = requests.post(
url,
data=soap_request_data,
cert=('cert.pem', 'key.pem'),
verify=False,
timeout=15,
headers=headers,
)
@skvsn Is your key encrypted? That is, does it have a passphrase?
Yes, it is encrypted. Do I have to provide unencrypted one? Or is there a way to pass the passphrase to requests?
Currently we have no way for you to provide the passphrase, so you'd have to decrypt it. =(
@Lukasa Thanks a lot. It works perfectly with unencrypted key. Probably worth mentioning this in the docs.
Agreed. =)
By the way, decrypting the key is really simple:
openssl rsa -in encrypted_key.pem -out unencrypted_key.pem
The following curl test works fine:
But the following python code hangs indefinitely on requests.post:
Last line never reached, the script hangs, no replies, no errors. Pressing Ctrl-C does not immediately abort but after several minutes prints:
Python 2.7 under Windows 7. Requests ver. 2.4.3. I don't have much experience with Internet connection programming, I don't even understand where to go from here. Any ideas why it doesn't work as intended?