Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
*.egg-info
*.so
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- 2.5
before_install:
- pip uninstall -y sslfix
- pip uninstall -y ssl # just to be sure
install:
- pip install .
script: python test/test_ssl.py
13 changes: 0 additions & 13 deletions MANIFEST

This file was deleted.

3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include Makefile README.rst
recursive-include test *
recursive-include ssl *.c *.h
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ clean:
.PHONY: test

test:
python setup.py test
python test/test_ssl.py
104 changes: 95 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,101 @@
This is a fixed version of ssl package (http://pypi.python.org/pypi/ssl).
ssl
===

To install it, do
The old socket.ssl() support for TLS over sockets is being
superseded in Python 2.6 by a new 'ssl' module. This package
brings that module to older Python releases, 2.3.5 and up (it may
also work on older versions of 2.3, but we haven't tried it).

pip install sslfix
It's quite similar to the 2.6 ssl module. There's no stand-alone
documentation for this package; instead, just use the development
branch documentation for the SSL module at
http://docs.python.org/dev/library/ssl.html.

or download it from http://pypi.python.org/pypy/sslfix
Version 1.0 had a problem with Python 2.5.1 -- the structure of
the socket object changed from earlier versions.

Note, that the actual package installed is `ssl` and not `sslfix` (it's a drop-in replacement).
Version 1.1 was missing various package metadata information.

The fixes are:
Version 1.2 added more package metadata, and support for
ssl.get_server_certificate(), and the PEM-to-DER encode/decode
routines. Plus integrated Paul Moore's patch to setup.py for
Windows. Plus added support for asyncore, and asyncore HTTPS
server test.

- Remove installing tests system-wide (fixes "permission denied" error when installing into virtualenv).
- Add /usr/lib/i386-linux-gnu and /usr/lib/x86_64-linux-gnu to search path (fixes compilation on ubuntu 12.04).
- Do not use SSLv2_method if not present (fixes ImportError: ssl/_ssl2.so: undefined symbol: SSLv2_method).
Version 1.3 fixed a bug in the test suite.

Version 1.4 incorporated use of -static switch.

Version 1.5 fixed bug in Python version check affecting build on
Python 2.5.0.

Version 1.7 (and 1.6) fixed some bugs with asyncore support (recv and
send not being called on the SSLSocket class, wrong semantics for
sendall).

Version 1.8 incorporated some code from Chris Stawarz to handle
sockets which are set to non-blocking before negotiating the SSL
session.

Version 1.9 makes ssl.SSLError a subtype of socket.error.

Version 1.10 fixes a bug in sendall().

Version 1.11 includes the MANIFEST file, and by default will turne
unexpected EOFs occurring during a read into a regular EOF. It also
removes the code for SSLFileStream, to use the regular socket module's
_fileobject instead.

Version 1.12 fixes the bug in SSLSocket.accept() reported by Georg
Brandl, and adds a test case for that fix.

Version 1.13 fixes a bug in calling do_handshake() automatically
on non-blocking sockets. Thanks to Giampaolo Rodola. Now includes
real asyncore test case.

Version 1.14 incorporates some fixes to naming (rename "recv_from" to
"recvfrom" and "send_to" to "sendto"), and a fix to the asyncore test
case to unregister the connection handler when the connection is
closed. It also exposes the SSL shutdown via the "unwrap" method
on an SSLSocket. It exposes "subjectPublicKey" in the data received
from a peer cert.

Version 1.15 fixes a bug in write retries, where the output buffer has
changed location because of garbage collection during the interim.
It also provides the new flag, PROTOCOL_NOSSLv2, which selects SSL23,
but disallows actual use of SSL2.

Version 1.16 removes installing tests system-wide (which fixes the
"permission denied" error when installing in virtualenvs), adds
``/usr/lib/i386-linux-gnu`` and ``/usr/lib/x86_64-linux-gnu`` to the
search path (which fixes compilation on ubuntu 12.04) and stopped using
``SSLv2_method`` if it's not present. Many thanks to `Denis Bilenko`_
for providing those fixes through his temporary sslfix_ fork.

The package is now maintained (bugfix only) by PyPA_.

Authorship: A cast of dozens over the years have written the Python
SSL support, including Marc-Alan Lemburg, Robin Dunn, GvR, Kalle
Svensson, Skip Montanaro, Mark Hammond, Martin von Loewis, Jeremy
Hylton, Andrew Kuchling, Georg Brandl, Bill Janssen, Chris Stawarz,
Neal Norwitz, and many others. Thanks to Paul Moore, David Bolen and
Mark Hammond for help with the Windows side of the house. And it's
all based on OpenSSL, which has its own cast of dozens!

.. _PyPA: https://github.com/pypa
.. _`Denis Bilenko`: https://github.com/denik
.. _`sslfix`: https://pypi.python.org/pypi/sslfix

Installation
------------

To install it, run::

pip install ssl

or download it from https://pypi.python.org/pypi/ssl

Issues
------

Feel free to report issues at https://github.com/pypa/ssl/issues
147 changes: 38 additions & 109 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os, sys
import codecs
import os
import re
import sys

from distutils.core import setup, Extension

if (sys.version_info >= (2, 6, 0)):
Expand Down Expand Up @@ -26,19 +30,21 @@ def find_file(filename, std_dirs, paths):
# Check the standard locations
for dir in std_dirs:
f = os.path.join(dir, filename)
print 'looking for', f
if os.path.exists(f): return []
print('looking for', f)
if os.path.exists(f):
return []

# Check the additional directories
for dir in paths:
f = os.path.join(dir, filename)
print 'looking for', f
print('looking for', f)
if os.path.exists(f):
return [dir]

# Not found anywhere
return None


def find_library_file(compiler, libname, std_dirs, paths):
result = compiler.find_library_file(std_dirs + paths, libname)
if result is None:
Expand All @@ -50,7 +56,7 @@ def find_library_file(compiler, libname, std_dirs, paths):
# Ensure path doesn't end with path separator
p = p.rstrip(os.sep)
if p == dirname:
return [ ]
return []

# Otherwise, it must have been in one of the additional directories,
# so we have to figure out which one.
Expand All @@ -72,24 +78,19 @@ def find_ssl():
inc_dirs = compiler.include_dirs + ['/usr/include']

search_for_ssl_incs_in = [
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/'
]
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
search_for_ssl_incs_in
)
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/',
]
ssl_incs = find_file('openssl/ssl.h', inc_dirs, search_for_ssl_incs_in)
if ssl_incs is not None:
krb5_h = find_file('krb5.h', inc_dirs,
['/usr/kerberos/include'])
if krb5_h:
ssl_incs += krb5_h

ssl_libs = find_library_file(compiler, 'ssl',
['/usr/lib', '/usr/lib/i386-linux-gnu', '/usr/lib/x86_64-linux-gnu'],
['/usr/local/lib',
'/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )
['/usr/lib', '/usr/lib/i386-linux-gnu', '/usr/lib/x86_64-linux-gnu'],
['/usr/local/lib', '/usr/local/ssl/lib', '/usr/contrib/ssl/lib/'])

if (ssl_incs is not None and ssl_libs is not None):
return ssl_incs, ssl_libs, ['ssl', 'crypto']
Expand All @@ -116,110 +117,38 @@ def find_ssl():
ssl_libs = [os.environ.get("C_LIB_DIR") or os.path.join(gnuwin32_dir, "lib")]
libs = ['ssl', 'crypto', 'wsock32']
if not dynamic:
libs = libs + ['gdi32', 'gw32c', 'ole32', 'uuid']
libs = libs + ['gdi32', 'gw32c', 'ole32', 'uuid']
link_args = ['-static']
else:
ssl_incs, ssl_libs, libs = find_ssl()


setup(name='sslfix',
version='1.15',
description='SSL wrapper for socket objects (2.3, 2.4, 2.5 compatible) (fixed setup.py)',
long_description=
"""
**This is a fixed version of ssl-1.15. It's a drop-in replacement for 'ssl' package.**

The fixes are:
- Remove installing tests system-wide (fixes "permission denied" error when installing into virtualenv).
- Add /usr/lib/i386-linux-gnu and /usr/lib/x86_64-linux-gnu to search path (fixes compilation on ubuntu 12.04).
- Do not use SSLv2_method if not present (fixes ImportError: ssl/_ssl2.so: undefined symbol: SSLv2_method).

See https://github.com/denik/sslfix

-------

The old socket.ssl() support for TLS over sockets is being
superseded in Python 2.6 by a new 'ssl' module. This package
brings that module to older Python releases, 2.3.5 and up (it may
also work on older versions of 2.3, but we haven't tried it).

It's quite similar to the 2.6 ssl module. There's no stand-alone
documentation for this package; instead, just use the development
branch documentation for the SSL module at
http://docs.python.org/dev/library/ssl.html.

Version 1.0 had a problem with Python 2.5.1 -- the structure of
the socket object changed from earlier versions.

Version 1.1 was missing various package metadata information.

Version 1.2 added more package metadata, and support for
ssl.get_server_certificate(), and the PEM-to-DER encode/decode
routines. Plus integrated Paul Moore's patch to setup.py for
Windows. Plus added support for asyncore, and asyncore HTTPS
server test.

Version 1.3 fixed a bug in the test suite.

Version 1.4 incorporated use of -static switch.

Version 1.5 fixed bug in Python version check affecting build on
Python 2.5.0.

Version 1.7 (and 1.6) fixed some bugs with asyncore support (recv and
send not being called on the SSLSocket class, wrong semantics for
sendall).

Version 1.8 incorporated some code from Chris Stawarz to handle
sockets which are set to non-blocking before negotiating the SSL
session.

Version 1.9 makes ssl.SSLError a subtype of socket.error.

Version 1.10 fixes a bug in sendall().

Version 1.11 includes the MANIFEST file, and by default will turne
unexpected EOFs occurring during a read into a regular EOF. It also
removes the code for SSLFileStream, to use the regular socket module's
_fileobject instead.

Version 1.12 fixes the bug in SSLSocket.accept() reported by Georg
Brandl, and adds a test case for that fix.

Version 1.13 fixes a bug in calling do_handshake() automatically
on non-blocking sockets. Thanks to Giampaolo Rodola. Now includes
real asyncore test case.

Version 1.14 incorporates some fixes to naming (rename "recv_from" to
"recvfrom" and "send_to" to "sendto"), and a fix to the asyncore test
case to unregister the connection handler when the connection is
closed. It also exposes the SSL shutdown via the "unwrap" method
on an SSLSocket. It exposes "subjectPublicKey" in the data received
from a peer cert.
def read(*parts):
here = os.path.abspath(os.path.dirname(__file__))
return codecs.open(os.path.join(here, *parts), 'r').read()

Version 1.15 fixes a bug in write retries, where the output buffer has
changed location because of garbage collection during the interim.
It also provides the new flag, PROTOCOL_NOSSLv2, which selects SSL23,
but disallows actual use of SSL2.

Authorship: A cast of dozens over the years have written the Python
SSL support, including Marc-Alan Lemburg, Robin Dunn, GvR, Kalle
Svensson, Skip Montanaro, Mark Hammond, Martin von Loewis, Jeremy
Hylton, Andrew Kuchling, Georg Brandl, Bill Janssen, Chris Stawarz,
Neal Norwitz, and many others. Thanks to Paul Moore, David Bolen and
Mark Hammond for help with the Windows side of the house. And it's
all based on OpenSSL, which has its own cast of dozens!
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")

""",

setup(name='ssl',
version=find_version('ssl', '__init__.py'),
description='SSL wrapper for socket objects (2.3, 2.4, 2.5 compatible)',
long_description=read('README.rst'),
license='Python (MIT-like)',
author='See long_description for details',
author_email='python.ssl.maintainer@gmail.com',
url='https://github.com/denik/sslfix',
author_email='distutils-sig@python.org',
url='https://github.com/pypa/ssl',
packages=['ssl'],
ext_modules=[Extension('ssl._ssl2', ['ssl/_ssl2.c'],
include_dirs = ssl_incs + [socket_inc],
library_dirs = ssl_libs,
libraries = libs,
extra_link_args = link_args)]
include_dirs=ssl_incs + [socket_inc],
library_dirs=ssl_libs,
libraries=libs,
extra_link_args=link_args)]
)
4 changes: 4 additions & 0 deletions ssl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
import base64 # for DER-to-PEM translation
import select # for handshake

# The version as used in the setup.py
__version__ = "1.16"


class SSLSocket (socket):

"""This class implements a subtype of socket.socket that wraps
Expand Down
26 changes: 0 additions & 26 deletions test/https_svn_python_org_root.pem

This file was deleted.

Loading