Skip to content

Commit

Permalink
Make keypairs optional (#14)
Browse files Browse the repository at this point in the history
* Make keypairs optional

* Update usage to show keypairs are optional
  • Loading branch information
dfornika authored Oct 9, 2020
1 parent 8330cbc commit d8369d8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ One can use [generate_certificates.py](https://github.com/zeromq/pyzmq/blob/mast

```
usage: publish_illumina_runs.py [-h] [--port PORT] [--path PATH]
[--heartbeat_interval HEARTBEAT_INTERVAL] --public_key PUBLIC_KEY
--private_key PRIVATE_KEY
[--heartbeat_interval HEARTBEAT_INTERVAL]
[--public_key PUBLIC_KEY] [--private_key PRIVATE_KEY]
optional arguments:
-h, --help show this help message and exit
Expand All @@ -39,7 +39,8 @@ publish_illumina_runs.py --path /path/to/sequencer-01 --path /path/to/sequencer-
A simple demo subscriber script is included. It simply prints messages from the `illumina_runs` topic to stdout.

```
usage: demo_subscriber.py [-h] [--port PORT] --public_key PUBLIC_KEY --private_key PRIVATE_KEY
usage: demo_subscriber.py [-h] [--port PORT]
[--public_key PUBLIC_KEY] [--private_key PRIVATE_KEY]
optional arguments:
-h, --help show this help message and exit
Expand Down
20 changes: 11 additions & 9 deletions demo_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ def main(args):
context = zmq.Context()
socket = context.socket(zmq.SUB)

client_secret_file = args.private_key
client_public, client_secret = zmq.auth.load_certificate(client_secret_file)
socket.curve_secretkey = client_secret
socket.curve_publickey = client_public
server_public_file = args.public_key
server_public, _ = zmq.auth.load_certificate(server_public_file)
socket.curve_serverkey = server_public
if args.public_key and args.private_key:
client_secret_file = args.private_key
client_public, client_secret = zmq.auth.load_certificate(client_secret_file)
socket.curve_secretkey = client_secret
socket.curve_publickey = client_public
server_public_file = args.public_key
server_public, _ = zmq.auth.load_certificate(server_public_file)
socket.curve_serverkey = server_public

print("Collecting updates from server...")
socket.connect("tcp://127.0.0.1:%s" % args.port)

Expand All @@ -31,7 +33,7 @@ def main(args):
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--port', default=5556)
parser.add_argument('--public_key', required=True)
parser.add_argument('--private_key', required=True)
parser.add_argument('--public_key')
parser.add_argument('--private_key')
args = parser.parse_args()
main(args)
23 changes: 13 additions & 10 deletions illumina_run_publisher/publish_illumina_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,23 @@ def heartbeat(socket, heartbeat_interval):
def main(args):

context = zmq.Context()
socket = context.socket(zmq.PUB)

auth = ThreadAuthenticator(context)
auth.start()
auth.allow('127.0.0.1')
auth.configure_curve(domain='*', location=zmq.auth.CURVE_ALLOW_ANY)

if args.public_key and args.private_key:
auth.configure_curve(domain='*', location=zmq.auth.CURVE_ALLOW_ANY)

server_public_file = args.public_key
server_secret_file = args.private_key
server_public, server_secret = zmq.auth.load_certificate(server_secret_file)
server_public_file = args.public_key
server_secret_file = args.private_key
server_public, server_secret = zmq.auth.load_certificate(server_secret_file)

socket = context.socket(zmq.PUB)
socket.curve_secretkey = server_secret
socket.curve_publickey = server_public
socket.curve_server = True
socket.curve_secretkey = server_secret
socket.curve_publickey = server_public
socket.curve_server = True

socket.bind("tcp://*:%s" % args.port)

miseq_run_dir_regex = ".+/\d{6}_[A-Z0-9]{6}_\d{4}_\d{9}-[A-Z0-9]{5}$"
Expand Down Expand Up @@ -138,7 +141,7 @@ def main(args):
parser.add_argument('--port', default=5556)
parser.add_argument('--path', action='append')
parser.add_argument('--heartbeat_interval', type=int, default=1)
parser.add_argument('--public_key', required=True)
parser.add_argument('--private_key', required=True)
parser.add_argument('--public_key')
parser.add_argument('--private_key')
args = parser.parse_args()
main(args)

0 comments on commit d8369d8

Please sign in to comment.