Skip to content

Commit 970c275

Browse files
committed
Merge branch 'node13h/master' into feature/v7
2 parents 6e4fd1b + c6b73dc commit 970c275

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

riemann_client/command.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ def echo_event(data):
5656
help='Timeout for TCP based connections.')
5757
@click.option('--ca-certs', '-C', type=click.Path(),
5858
help='A CA certificate bundle for TLS connections.')
59+
@click.option('--keyfile', type=click.Path(),
60+
help='Private client key for TLS connections.')
61+
@click.option('--certfile', type=click.Path(),
62+
help='Public client certificate for TLS connections.')
5963
@click.pass_context
60-
def main(ctx, host, port, transport_type, timeout, ca_certs):
64+
def main(ctx, host, port, transport_type, timeout, ca_certs, keyfile, certfile):
6165
"""Connects to a Riemann server to send events or query the index
6266
6367
By default, will attempt to contact Riemann on localhost:5555 over TCP. The
@@ -77,7 +81,7 @@ def main(ctx, host, port, transport_type, timeout, ca_certs):
7781
if ca_certs is None:
7882
ctx.fail('--ca-certs must be set when using the TLS transport')
7983
transport = TLSTransport(
80-
host, port, timeout, ca_certs)
84+
host, port, timeout, ca_certs, keyfile, certfile)
8185
elif transport_type == 'none':
8286
transport = BlankTransport()
8387

riemann_client/transport.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,20 @@ def send(self, message):
148148

149149

150150
class TLSTransport(TCPTransport):
151-
def __init__(self, host=HOST, port=PORT, timeout=TIMEOUT, ca_certs=None):
151+
def __init__(self, host=HOST, port=PORT, timeout=TIMEOUT, ca_certs=None,
152+
keyfile=None, certfile=None):
152153
"""Communicates with Riemann over TCP + TLS
153154
154155
Options are the same as :py:class:`.TCPTransport` unless noted
155156
156157
:param str ca_certs: Path to a CA Cert bundle used to create the socket
158+
:param str keyfile: Path to a client key file
159+
:param str certfile: Path to a client certificate file
157160
"""
158161
super(TLSTransport, self).__init__(host, port, timeout)
159162
self.ca_certs = ca_certs
163+
self.keyfile = keyfile
164+
self.certfile = certfile
160165

161166
def connect(self):
162167
"""Connects using :py:meth:`TLSTransport.connect` and wraps with TLS"""
@@ -165,7 +170,9 @@ def connect(self):
165170
self.socket,
166171
ssl_version=ssl.PROTOCOL_TLSv1,
167172
cert_reqs=ssl.CERT_REQUIRED,
168-
ca_certs=self.ca_certs)
173+
ca_certs=self.ca_certs,
174+
keyfile=self.keyfile,
175+
certfile=self.certfile)
169176

170177

171178
class BlankTransport(Transport):

0 commit comments

Comments
 (0)