diff --git a/rhn/SSL.py b/rhn/SSL.py index db26fd8541..c3d338868f 100644 --- a/rhn/SSL.py +++ b/rhn/SSL.py @@ -28,6 +28,7 @@ from OpenSSL import SSL # SSL.crypto is provided to other modules from OpenSSL import crypto import os +import sys import socket import select @@ -134,7 +135,19 @@ class SSLSocket: self._makefile_called = self._makefile_called - 1 def _really_close(self): - self._connection.shutdown() + # No connection was established + if self._connection is None: + return + + # for Python 3 + if sys.version_info[0] == 3: + if self._connection.get_state_string() == b'SSL negotiation finished successfully': + self._connection.shutdown() + # for Python 2 + else: + if self._connection.state_string() == 'SSL negotiation finished successfully': + self._connection.shutdown() + self._connection.close() self._closed = 1 diff --git a/rhnlib.spec b/rhnlib.spec index 2de48689f4..57e2128001 100644 --- a/rhnlib.spec +++ b/rhnlib.spec @@ -5,7 +5,7 @@ Name: rhnlib URL: https://fedorahosted.org/spacewalk Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz Version: 2.5.65 -Release: 4%{?dist} +Release: 5%{?dist} Group: Development/Libraries License: GPLv2 @@ -59,6 +59,10 @@ rm -rf $RPM_BUILD_ROOT %{python_sitelib}/* %changelog +* Thu Sep 21 2017 Tomas Kasparek 2.5.65-5 +- Resolves: #1471045 - check a state of handshake before shutdown SSL + connection (grinrag@gmail.com) + * Mon Mar 06 2017 Gennadii Altukhov 2.5.65-4 - Resolves: #1409577 - fixed BZ ID in changelog (galt@redhat.com)