mirror of https://github.com/n1nj4sec/pupy.git
Delete-then-raise for tmp certs
This commit is contained in:
parent
93ddf8015d
commit
26af5ad760
|
@ -121,6 +121,8 @@ class PupySSLClient(PupyTCPClient):
|
|||
os.write(fd_ca_path, self.SSL_CA_CERT)
|
||||
os.close(fd_ca_path)
|
||||
|
||||
exception = None
|
||||
|
||||
try:
|
||||
wrapped_socket = ssl.wrap_socket(
|
||||
socket,
|
||||
|
@ -132,11 +134,17 @@ class PupySSLClient(PupyTCPClient):
|
|||
ssl_version=self.ssl_version,
|
||||
ciphers=self.ciphers
|
||||
)
|
||||
except Exception as e:
|
||||
exception = e
|
||||
|
||||
finally:
|
||||
os.unlink(tmp_cert_path)
|
||||
os.unlink(tmp_key_path)
|
||||
os.unlink(tmp_ca_path)
|
||||
|
||||
if exception:
|
||||
raise e
|
||||
|
||||
peer = wrapped_socket.getpeercert()
|
||||
|
||||
peer_role = ''
|
||||
|
|
|
@ -40,6 +40,8 @@ class PupySSLAuthenticator(object):
|
|||
os.write(fd_ca_path, self.castr)
|
||||
os.close(fd_ca_path)
|
||||
|
||||
exception = None
|
||||
|
||||
try:
|
||||
wrapped_socket = ssl.wrap_socket(
|
||||
sock,
|
||||
|
@ -52,14 +54,15 @@ class PupySSLAuthenticator(object):
|
|||
ciphers=self.ciphers
|
||||
)
|
||||
except ssl.SSLError:
|
||||
ex = sys.exc_info()[1]
|
||||
raise AuthenticationError(str(ex))
|
||||
exception = sys.exc_info()[1]
|
||||
|
||||
finally:
|
||||
os.unlink(tmp_cert_path)
|
||||
os.unlink(tmp_key_path)
|
||||
os.unlink(tmp_ca_path)
|
||||
|
||||
if exception:
|
||||
raise AuthenticationError(str(exception))
|
||||
|
||||
peer = wrapped_socket.getpeercert()
|
||||
peer_role = ''
|
||||
|
|
Loading…
Reference in New Issue