Commit e391999d authored by Michal Horejsek's avatar Michal Horejsek

Pass keys as file names instead of values

parent f83d72a7
......@@ -11,9 +11,9 @@ with the following command:
$ ssh-keygen -t rsa -b 4096
Store it in some path and then pass it as arguments:
Store it in some path and then pass file names as arguments:
--public-key "$(< /path/" --private-key "$(< /path/id_rsa)"
--public-key /path/ --private-key /path/id_rsa
Example usage:
......@@ -11,6 +11,15 @@ from zope.interface import implementer
from haas_proxy import ProxyService, constants, __doc__ as haas_proxy_doc
def read_key(filename, default):
if not filename:
return default
return open(filename).read()
except Exception as exc:
raise usage.UsageError('Problem to read the key {}: {}'.format(filename, exc))
class Options(usage.Options):
optParameters = [
['device-token', 'd', None, 'Your ID at If you don\'t have one, sign up first.'],
......@@ -48,10 +57,8 @@ class Options(usage.Options):
def postOptions(self):
if not self['device-token']:
raise usage.UsageError('Device token is required')
if not self['public-key']:
self['public-key'] = constants.DEFAULT_PUBLIC_KEY
if not self['private-key']:
self['private-key'] = constants.DEFAULT_PRIVATE_KEY
self['public-key'] = read_key(self['public-key'], constants.DEFAULT_PUBLIC_KEY)
self['private-key'] = read_key(self['private-key'], constants.DEFAULT_PRIVATE_KEY)
def getSynopsis(self):
return super(Options, self).getSynopsis() + '\n' + haas_proxy_doc
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