Problem mit SSL Socket
Verfasst: Mittwoch 15. Mai 2013, 20:23
Hallo Zusammen,
ich bin ein Pythonfrischling und Programmiere auf einem Raspberry Pi.
Ich versuche gerade mit Hilfe der Python Dokumentation eine SSL-Verbindung zum Server bwin.com aufzubauen nur leider funktioniert das nicht!
Hier der Code:
Es passiert erst lange garnichts und dann erscheint diese Ausgabe:
Ich benutze dieses Zertifikat:
http://curl.haxx.se/ca/cacert.pem
Mit anderen Servern, funktioniert der Code :/
Hoffe einer von euch hat eine Idee woran es liegen könnte!
ich bin ein Pythonfrischling und Programmiere auf einem Raspberry Pi.
Ich versuche gerade mit Hilfe der Python Dokumentation eine SSL-Verbindung zum Server bwin.com aufzubauen nur leider funktioniert das nicht!
Hier der Code:
Code: Alles auswählen
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# require a certificate from the server
ssl_sock = ssl.wrap_socket(s,
ca_certs="/etc/ssl/certs/cacerts.pem",
cert_reqs=ssl.CERT_REQUIRED)
HOST = 'www.bwin.com'
ssl_sock.connect((HOST, 443))
print repr(ssl_sock.getpeername())
print ssl_sock.cipher()
print pprint.pformat(ssl_sock.getpeercert())
# Set a simple HTTP request -- use httplib in actual code.
ssl_sock.write("""GET /de/livebets.aspx?zoneid=in10937 HTTP/1.1\r\n
"Host: """ + HOST + """\r\n
"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0\r\n
"Accept: text/html\r\n
"Connetion: close\r\n
"Content-Type: application/x-www-form-urlencoded\r\n\r\n""")
# Read a chunk of data. Will not necessarily
# read all the data returned by the server.
data = ssl_sock.read()
# note that closing the SSLSocket will also close the underlying socket
ssl_sock.close()
print data
Code: Alles auswählen
Traceback (most recent call last):
File "SSLTest.py", line 10, in <module>
ssl_sock.connect((HOST, 443))
File "/usr/lib/python2.7/ssl.py", line 331, in connect
self._real_connect(addr, False)
File "/usr/lib/python2.7/ssl.py", line 324, in _real_connect
raise e
socket.error: [Errno 104] Connection reset by peer
------------------
(program exited with code: 1)
Press return to continue
http://curl.haxx.se/ca/cacert.pem
Mit anderen Servern, funktioniert der Code :/
Hoffe einer von euch hat eine Idee woran es liegen könnte!