[Python-de] SSL in python-2.1.2?

clemensF ino-waiting at gmx.net
Tue Mar 12 13:14:39 EST 2002


zunaechst mal vielen dank fuer diese konstruktive hilfe.

> Gerhard Häring:

> Eine Übersicht (na ja, eher nur eine Auflistung) der Alternativen
> findest du auf meiner Homepage. Am ausgereiftesten dürfte wohl m2crypto
> sein, das gibt es schon am längsten. Natürlich hat das auch HTTPS usw.

das habe ich noch nicht getestet, kommt aber demnaechst dran.

> Btw. ich wüsste schon, wie man Python's SSL-Fähigkeiten testen könnte,
> der Haken ist nur, dass dieser Test (wohl wegen Bugs in der
> SSL-Implementierung vom Socket Modul) fehlschlägt.
> 
> - Ein selbst-signiertes Zertifikat erstellen und unter server.pem
>   abspeichern
> - openssl s_server -www
> - quick'n dirty Python test:
> 
> import urllib
> url = "https://localhost:4433"
> #url = "https://sf.net/"
> print urllib.urlopen(url).read()
> 
> ==> socket.sslerror: (5, 'EOF occurred in violation of protocol')

mit python2.0 funktioniert das tadellos, ich habe ein script, das
regelmaessig einen update ueber https:// macht, und das klappt auch.

bei python-2.1.2 jedoch passiert folgendes:

0 p1 tmp #python2.1
Python 2.1.2 (#5, Mar 11 2002, 16:43:02)
[GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> import urllib
>>> url = "https://localhost:433"
>>> print urllib.urlopen(url).read()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.1/urllib.py", line 71, in urlopen
    return _urlopener.open(url)
  File "/usr/local/lib/python2.1/urllib.py", line 176, in open
    return getattr(self, name)(url)
  File "/usr/local/lib/python2.1/urllib.py", line 361, in open_https
    h.putrequest('GET', selector)
  File "/usr/local/lib/python2.1/httplib.py", line 437, in putrequest
    self.send(str)
  File "/usr/local/lib/python2.1/httplib.py", line 379, in send
    self.connect()
  File "/usr/local/lib/python2.1/httplib.py", line 635, in connect
    sock.connect((self.host, self.port))
IOError: [Errno socket error] (61, 'Connection refused')

die modules werden in folgender reihenfolge initialisiert:

0 p1 tmp #python2.1 -v
# /usr/local/lib/python2.1/site.pyc matches /usr/local/lib/python2.1/site.py
import site # precompiled from /usr/local/lib/python2.1/site.pyc
# /usr/local/lib/python2.1/os.pyc matches /usr/local/lib/python2.1/os.py
import os # precompiled from /usr/local/lib/python2.1/os.pyc
import posix # builtin
# /usr/local/lib/python2.1/posixpath.pyc matches /usr/local/lib/python2.1/posixpath.py
import posixpath # precompiled from /usr/local/lib/python2.1/posixpath.pyc
# /usr/local/lib/python2.1/stat.pyc matches /usr/local/lib/python2.1/stat.py
import stat # precompiled from /usr/local/lib/python2.1/stat.pyc
# /usr/local/lib/python2.1/UserDict.pyc matches /usr/local/lib/python2.1/UserDict.py
import UserDict # precompiled from /usr/local/lib/python2.1/UserDict.pyc
Python 2.1.2 (#5, Mar 11 2002, 16:43:02)
[GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4
Type "copyright", "credits" or "license" for more information.
import readline # builtin
>>> import urllib
# /usr/local/lib/python2.1/urllib.pyc matches /usr/local/lib/python2.1/urllib.py
import urllib # precompiled from /usr/local/lib/python2.1/urllib.pyc
# /usr/local/lib/python2.1/string.pyc matches /usr/local/lib/python2.1/string.py
import string # precompiled from /usr/local/lib/python2.1/string.pyc
import strop # dynamically loaded from /usr/local/lib/python2.1/lib-dynload/strop.so
# /usr/local/lib/python2.1/socket.pyc matches /usr/local/lib/python2.1/socket.py
import socket # precompiled from /usr/local/lib/python2.1/socket.pyc
import _socket # builtin
# /usr/local/lib/python2.1/types.pyc matches /usr/local/lib/python2.1/types.py
import types # precompiled from /usr/local/lib/python2.1/types.pyc
>>> url="HTTPS://localhost:443"
>>> print urllib.urlopen(url).read()
# /usr/local/lib/python2.1/re.pyc matches /usr/local/lib/python2.1/re.py
import re # precompiled from /usr/local/lib/python2.1/re.pyc
# /usr/local/lib/python2.1/sre.pyc matches /usr/local/lib/python2.1/sre.py
import sre # precompiled from /usr/local/lib/python2.1/sre.pyc
# /usr/local/lib/python2.1/sre_compile.pyc matches /usr/local/lib/python2.1/sre_compile.py
import sre_compile # precompiled from /usr/local/lib/python2.1/sre_compile.pyc
import _sre # builtin
# /usr/local/lib/python2.1/sre_constants.pyc matches /usr/local/lib/python2.1/sre_constants.py
import sre_constants # precompiled from /usr/local/lib/python2.1/sre_constants.pyc
# /usr/local/lib/python2.1/sre_parse.pyc matches /usr/local/lib/python2.1/sre_parse.py
import sre_parse # precompiled from /usr/local/lib/python2.1/sre_parse.pyc
# /usr/local/lib/python2.1/copy_reg.pyc matches /usr/local/lib/python2.1/copy_reg.py
import copy_reg # precompiled from /usr/local/lib/python2.1/copy_reg.pyc
# /usr/local/lib/python2.1/httplib.pyc matches /usr/local/lib/python2.1/httplib.py
import httplib # precompiled from /usr/local/lib/python2.1/httplib.pyc
# /usr/local/lib/python2.1/mimetools.pyc matches /usr/local/lib/python2.1/mimetools.py
import mimetools # precompiled from /usr/local/lib/python2.1/mimetools.pyc
# /usr/local/lib/python2.1/rfc822.pyc matches /usr/local/lib/python2.1/rfc822.py
import rfc822 # precompiled from /usr/local/lib/python2.1/rfc822.pyc
import time # dynamically loaded from /usr/local/lib/python2.1/lib-dynload/time.so
# /usr/local/lib/python2.1/tempfile.pyc matches /usr/local/lib/python2.1/tempfile.py
import tempfile # precompiled from /usr/local/lib/python2.1/tempfile.pyc
import thread # builtin
import cStringIO # builtin

sagt das was wesentliches aus?

> Ich hab an Python's SSL auch mal ein bischen Bugfixing betrieben und
> jemand hat mir da mal einen Patch mit einem Würgaround gemailt. Ich
> schau mal, ob der das Problem fixt.

dufte.

clemens fischer



More information about the Python-de mailing list