Blame SOURCES/rhnlib-2.5.65-4-el7-to-rhnlib-2.5.65-5-el7.patch

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