Skip to content

Commit ecf1ddb

Browse files
committed
cli: Add auth blob
Persist the auth blob and try to use it to set up tls. This does not add the rune to the scheduler yet, but this is comming in a next step. Signed-off-by: Peter Neuroth <[email protected]>
1 parent b1fed10 commit ecf1ddb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tools/glcli/glcli/cli.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ class Tls:
3232
"""
3333
def __init__(self):
3434
self.tls = TlsConfig()
35+
# Try to load auth blob first
36+
auth_path = Path('greenlight.auth')
3537
cert_path = Path('device.crt')
3638
key_path = Path('device-key.pem')
3739
have_certs = cert_path.exists() and key_path.exists()
38-
if have_certs:
40+
if auth_path.exists():
41+
with auth_path.open('rb') as f:
42+
self.tls = self.tls.identity_from_auth(f.read())
43+
logger.info("Configuring client with user identity from auth file.")
44+
elif have_certs:
3945
device_cert = open('device.crt', 'rb').read()
4046
device_key = open('device-key.pem', 'rb').read()
4147
self.tls = self.tls.identity(device_cert, device_key)
@@ -232,6 +238,9 @@ def register(ctx, network, invite):
232238

233239
with open("ca.pem", "wb") as f:
234240
f.write(env.ca_pem)
241+
242+
with open("greenlight.auth", "wb") as f:
243+
f.write(res.auth)
235244

236245
pbprint(res)
237246

@@ -255,6 +264,9 @@ def recover(ctx):
255264
with open("ca.pem", "wb") as f:
256265
f.write(env.ca_pem)
257266

267+
with open("greenlight.auth", "wb") as f:
268+
f.write(res.auth)
269+
258270
pbprint(res)
259271

260272

0 commit comments

Comments
 (0)