Commit 940eae0c authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2962] Don't raise another exception, but re-raise the same one

... so that we have backtrace of what actual problem caused it.
parent 4bca9c53
......@@ -601,12 +601,13 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
# error)
return ssl_sock
except ssl.SSLError as err:
self.close_request(sock)
logger.error(CMDCTL_SSL_SETUP_FAILURE_USER_DENIED, err)
raise
except (CmdctlException, IOError) as cce:
self.close_request(sock)
logger.error(CMDCTL_SSL_SETUP_FAILURE_READING_CERT, cce)
self.close_request(sock)
# raise socket error to finish the request
raise socket.error
raise
def get_request(self):
'''Get client request socket and wrap it in SSL context. '''
......
......@@ -15,7 +15,7 @@
import unittest
import socket
import ssl, socket
import tempfile
import time
import stat
......@@ -729,16 +729,15 @@ class TestSecureHTTPServer(unittest.TestCase):
def test_wrap_sock_in_ssl_context(self):
sock = socket.socket()
# Bad files should result in a socket.error raised by our own
# code in the basic file checks
self.assertRaises(socket.error,
# Bad files should result in a CmdctlException in the basic file
# checks
self.assertRaises(CmdctlException,
self.server._wrap_socket_in_ssl_context,
sock,
'no_such_file', 'no_such_file')
# Using a non-certificate file would cause an SSLError, which
# is caught by our code which then raises a basic socket.error
self.assertRaises(socket.error,
# Using a non-certificate file would cause an SSLError
self.assertRaises(ssl.SSLError,
self.server._wrap_socket_in_ssl_context,
sock,
BUILD_FILE_PATH + 'cmdctl.py',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment