Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions rfc5424logging/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(
tls_client_cert=None,
tls_client_key=None,
tls_key_password=None,
tls_ciphers=None,
stream=None,
):
"""
Expand Down Expand Up @@ -189,6 +190,8 @@ def __init__(
Path to a file containing the client private key.
tls_key_password (str):
Optionally the password for decrypting the specified private key.
tls_ciphers (str):
Optionally the ciphers to use in the TLS connection.
stream (io.BufferedIOBase, file, io.TextIOBase):
Optionally a stream object to send the message to. See https://docs.python.org/3/library/io.html
for details.
Expand All @@ -215,6 +218,7 @@ def __init__(
self.tls_client_cert = tls_client_cert
self.tls_client_key = tls_client_key
self.tls_key_password = tls_key_password
self.tls_ciphers = tls_ciphers
self.stream = stream
self.transport = None

Expand All @@ -237,9 +241,15 @@ def _setup_transport(self):
if self.socktype == socket.SOCK_STREAM:
if self.tls_enable:
self.transport = transport.TLSSocketTransport(
self.address, self.timeout, self.framing,
self.tls_ca_bundle, self.tls_verify,
self.tls_client_cert, self.tls_client_key, self.tls_key_password
self.address,
self.timeout,
self.framing,
self.tls_ca_bundle,
self.tls_verify,
self.tls_client_cert,
self.tls_client_key,
self.tls_key_password,
self.tls_ciphers,
)
else:
self.transport = transport.TCPSocketTransport(self.address, self.timeout, self.framing)
Expand Down
4 changes: 4 additions & 0 deletions rfc5424logging/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,23 @@ def __init__(
tls_client_cert,
tls_client_key,
tls_key_password,
tls_ciphers,
):
self.tls_ca_bundle = tls_ca_bundle
self.tls_verify = tls_verify
self.tls_client_cert = tls_client_cert
self.tls_client_key = tls_client_key
self.tls_key_password = tls_key_password
self.tls_ciphers = tls_ciphers
super(TLSSocketTransport, self).__init__(address, timeout, framing=framing)

def open(self):
super(TLSSocketTransport, self).open()
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH, cafile=self.tls_ca_bundle
)
if self.tls_ciphers:
context.set_ciphers(self.tls_ciphers)
context.verify_mode = ssl.CERT_REQUIRED if self.tls_verify else ssl.CERT_NONE
server_hostname, _ = self.address
if self.tls_client_cert:
Expand Down