File python-backports.ssl_match_hostname.spec of Package python-backports.ssl_match_hostname.3892

#
# spec file for package python-backports.ssl_match_hostname
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           python-backports.ssl_match_hostname
Version:        3.4.0.2
Release:        0
Summary:        The ssl.match_hostname() function from Python 3.4
License:        Python-2.0
Group:          Development/Languages/Python
Url:            http://bitbucket.org/brandon/backports.ssl_match_hostname
Source:         https://pypi.python.org/packages/source/b/backports.ssl_match_hostname/backports.ssl_match_hostname-%{version}.tar.gz
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch:      noarch
%endif

%description
The Secure Sockets layer is only actually *secure*
if you check the hostname in the certificate returned
by the server to which you are connecting,
and verify that it matches to hostname
that you are trying to reach.

But the matching logic, defined in `RFC2818`_,
can be a bit tricky to implement on your own.
So the ``ssl`` package in the Standard Library of Python 3.2
and greater now includes a ``match_hostname()`` function
for performing this check instead of requiring every application
to implement the check separately.

This backport brings ``match_hostname()`` to users
of earlier versions of Python.
Simply make this distribution a dependency of your package,
and then use it like this::

    from backports.ssl_match_hostname import match_hostname, CertificateError
    ...
    sslsock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_SSLv3,
                              cert_reqs=ssl.CERT_REQUIRED, ca_certs=...)
    try:
        match_hostname(sslsock.getpeercert(), hostname)
    except CertificateError, ce:
        ...

%prep
%setup -q -n backports.ssl_match_hostname-%{version}

%build
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

%files
%defattr(-,root,root,-)
%dir %{python_sitelib}/backports/
%{python_sitelib}/backports/__init__.py*
%dir %{python_sitelib}/backports/ssl_match_hostname/
%doc %{python_sitelib}/backports/ssl_match_hostname/LICENSE.txt
%doc %{python_sitelib}/backports/ssl_match_hostname/README.txt
%{python_sitelib}/backports/ssl_match_hostname/__init__.py*
%{python_sitelib}/backports.ssl_match_hostname-%{version}-py*.egg-info

%changelog
openSUSE Build Service is sponsored by