Christopher Arndt <[email protected]> wrote:
> Am 23.03.25 um 02:29 schrieb Ulli Horlacher:
>>
>> sock = ssl.SSLContext.wrap_socket(sock)
>>
>> Ich hab da wohl was nicht verstanden. Wie gehts richtig?
>
> Du musst die wrap_socket Methode auf einer *Instanz* der Klasse
> SSLContext aufrufen.
Mit Klassen hab ich bisher noch nicht gearbeitet, jedenfalls nicht
explizit.
> Diese Instanz erzeugst du am besten mit:
>
> context = ssl.create_default_context()
Ich hab das nun so probiert:
sock = socket.create_connection((server,port))
(...)
SSLContext = ssl.create_default_context()
sock = SSLContext.wrap_socket(sock)
Das ergibt leider die Fehlermeldung:
File "/local/home/framstag/python/./fexit.py", line 906, in http_connect
sock = SSLContext.wrap_socket(sock)
File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.10/ssl.py", line 1028, in _create
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
Dabei hattte ich doch den Server hostname angegeben bei Erzeugung von sock.
> Hier gibt es Beispielcode:
>
> https://docs.python.org/3/library/ssl.html#socket-creation
Da ist leider kein Beispiel dabei, wie man einen vorhandenen socket in
einen TLS socket wandelt, wie es zuvor bei Python2 ging mit:
sock = ssl.wrap_socket(sock)
Bzw es geht so ja noch immer, nur kommt da die Warnung.
Die will ich wegkriegen.
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: [email protected]
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: https://www.tik.uni-stuttgart.de/
_______________________________________________
python-de Mailingliste -- [email protected]
Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an
[email protected]
https://mail.python.org/mailman3/lists/python-de.python.org/
Mitgliedsadresse: [email protected]