From 9352d2fc10dde6ed8cc57f2acee3e27ed7e340c2 Mon Sep 17 00:00:00 2001 From: rcrit Date: Tue, 30 Jun 2009 16:34:40 -0400 Subject: Add a local implementation of httplib.SSLFile and httplib.FakeSocket Python 2.6 changed its internal implementation which makes it difficult to override in a way that is backwards compatible. 508953 --- ipapython/nsslib.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ipapython/nsslib.py') diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py index fd27028e..1b678305 100644 --- a/ipapython/nsslib.py +++ b/ipapython/nsslib.py @@ -27,6 +27,13 @@ import nss.io as io import nss.nss as nss import nss.ssl as ssl +try: + from httplib import SSLFile + from httplib import FakeSocket +except ImportError: + from ipapython.ipasslfile import SSLFile + from ipapython.ipasslfile import FakeSocket + def client_auth_data_callback(ca_names, chosen_nickname, password, certdb): cert = None if chosen_nickname: @@ -49,7 +56,7 @@ def client_auth_data_callback(ca_names, chosen_nickname, password, certdb): return False return False -class SSLFile(httplib.SSLFile): +class SSLFile(SSLFile): """ Override the _read method so we can use the NSS recv method. """ @@ -64,7 +71,7 @@ class SSLFile(httplib.SSLFile): break return buf -class NSSFakeSocket(httplib.FakeSocket): +class NSSFakeSocket(FakeSocket): def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() -- cgit