-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sshnp exit if atSign DNE, sshnpd wait for atSign to exist #211
Conversation
@cconstab |
lib/atsign_exists.dart
Outdated
/// Checks if the provided atSign's atServer has been properly activated with a public RSA key. | ||
/// `atClient` must be authenticated | ||
/// `atSign` is the atSign to check | ||
Future<bool> atSignIsActivated(final AtClient atClient, String atSign) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add into the sshnp_utils.dart please? Keeps things tidy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/atsign_exists.dart
Outdated
try { | ||
await atClient.get(publicKey); | ||
return true; | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you distinguish between errors? For example if the atServer is not reachable for some reason, that is different than getting a KeyNotFound exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, is this what you mean?
The AtClient.get
exceptions are:
Throws [AtKeyException] for the invalid key formed
Throws [AtDecryptionException] if fails to decrypt the value
Throws [AtPrivateKeyNotFoundException] if the encryption private key is not found to decrypt the value
Throws [AtPublicKeyChangeException] if the encryption public key used encrypt the value
is different from the current encryption public key(at the time of decryption)
Throws [SharedKeyNotFoundException] if the shared key to decrypt the value is not found
Throws [SelfKeyNotFoundException] if the self encryption key is not found.
Throws [AtClientException] if the cloud secondary is invalid or not reachable
The only 2 possible exceptions should be AtKeyException and AtClientException, right?
lib/sshnp.dart
Outdated
@@ -177,6 +178,10 @@ class SSHNP { | |||
throw StateError('Cannot init() - already initialized'); | |||
} | |||
|
|||
if(!(await atSignIsActivated(atClient, sshnpdAtSign))) { | |||
throw ('sshnpd atSign $sshnpdAtSign does not exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your current implementation, it might exist, but not yet be onboarded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message was incorrect
e2fd442
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, an atSign can have a publickey
but not be onboarded?
EDIT
I find that it does not exist, as long as we bypass cache
@jeremy_0 plookup:bypassCache:true:publickey@slow674
=> error:{"errorCode":"AT0011","errorDescription":"Internal server exception : Request to remote secondary @slow674 at null:null received error response 'AT0015-Exception: public:publickey@slow674 does not exist in keystore'"}
@jeremy_0 plookup:publickey@slow674
=> data:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl6HAhNfIC+gTPzVNk6ptm8rWLe2I2nDhktEFGlFUuNaHF7T4lS+n9zVLApKbwL/tXEMJAFZ2B7YhLJh4BILsAxsjMqTUuiMNVzpuWKEr3o06Nr7VBzu1n0PVcHdB1akj/pHhk60D7HWzqN2FZBYS0h1rYeVjpDVCh/WxPtqg/0f7sEv4uWpsWFivQVh7UPp5zB8fAj2ypmSyEvuMDU63N8pUUSmAWr7qKbuE+4Jj8QPY7C6CBBHjukMd5+oqkKGSqEkSn8enc22KLaFJiXkKKbqxVhLHBMCLsUl+1krxeFNU2PmTAcc6Ek+yby7XM0erhy99vbkaAC/cCuSeSS2qjQIDAQAB
@JeremyTubongbanua - @cconstab and I discussed this last week ... we think a |
f6fb133
to
26fccd8
Compare
Here's the results of my testing as of the most recent commit: Testing that atsign@6d0c777a3b17:~/.local/bin$ ./sshnp -f @jeremy_0 -t @noblesnowbaboon -s id_ed25519.pub -d docker -h @rv_am
Unhandled exception:
sshnpd atSign @noblesnowbaboon is not activated.
#0 SSHNP.init (package:sshnoports/sshnp.dart:181)
<asynchronous suspension>
#1 main (file:///build/repo/bin/sshnp.dart:21)
<asynchronous suspension> Testing that atsign@8ea01a4b8c7a:~/.local/bin$ ./sshnpd -a @smoothalligator -m @noblesnowbaboon -d docker -s -u -v
...
WARNING|2023-06-27 04:40:25.940721| sshnpd |Waiting for @noblesnowbaboon to be activated...
WARNING|2023-06-27 04:40:31.130089| sshnpd |Waiting for @noblesnowbaboon to be activated...
WARNING|2023-06-27 04:40:36.445747| sshnpd |Waiting for @noblesnowbaboon to be activated... Here are the WARNING|2023-06-27 04:42:52.471506| sshnpd |Waiting for @noblesnowbaboon to be activated...
INFO|2023-06-27 04:42:52.899482|AbstractAtKeyEncryption (@smoothalligator)|Encrypted shared symmetric key for @smoothalligator not found in local storage
INFO|2023-06-27 04:42:52.899658|AbstractAtKeyEncryption (@smoothalligator)|Deleting @noblesnowbaboon:shared_key@smoothalligator from LocalSecondary
INFO|2023-06-27 04:42:52.900637|AbstractAtKeyEncryption (@smoothalligator)|Fetching shared symmetric key for @smoothalligator from atServer
INFO|2023-06-27 04:42:52.961281|AbstractAtKeyEncryption (@smoothalligator)|Creating new shared symmetric key as @smoothalligator for @noblesnowbaboon
INFO|2023-06-27 04:42:52.963822|AbstractAtKeyEncryption (@smoothalligator)|Deleting @noblesnowbaboon:shared_key@smoothalligator from RemoteSecondary
INFO|2023-06-27 04:42:53.072124|AbstractAtKeyEncryption (@smoothalligator)|Storing new shared symmetric key to atServer
INFO|2023-06-27 04:42:53.144331|AbstractAtKeyEncryption (@smoothalligator)|Storing new shared symmetric key to local storage
INFO|2023-06-27 04:42:53.145216|AbstractAtKeyEncryption (@smoothalligator)|'Their' copy of shared symmetric key for @noblesnowbaboon not found in local storage - will check atServer
INFO|2023-06-27 04:42:53.271397|AbstractAtKeyEncryption (@smoothalligator)|Saving 'their' copy of shared symmetric key for @noblesnowbaboon to atServer
INFO|2023-06-27 04:42:53.339776|AbstractAtKeyEncryption (@smoothalligator)|Saving 'their' copy of shared symmetric key for @noblesnowbaboon to local storage
INFO|2023-06-27 04:42:54.041067| sshnpd |SUCCESS:id: 270e510e-412e-4666-83f8-39866465410c status: NotificationStatusEnum.delivered atsign
INFO|2023-06-27 04:42:55.103470|SyncService (@smoothalligator)|72717253|Returning serverCommitId 32573
INFO|2023-06-27 04:42:55.168053|SyncService (@smoothalligator)|72717253|Returning serverCommitId 32573
SEVERE|2023-06-27 04:42:55.281406|EncryptionUtil|Error while decrypting value: Invalid argument(s): Invalid or corrupted pad block
WARNING|2023-06-27 04:42:55.281474|SyncService (@smoothalligator)|Exception occurred when setting conflict info for @noblesnowbaboon:shared_key@smoothalligator | Exception: Invalid argument(s): Invalid or corrupted pad block
INFO|2023-06-27 04:42:55.367503|SyncService (@smoothalligator)|72717253|Inside syncComplete. syncRequest.requestSource : SyncRequestSource.system; syncRequest.onDone : Closure: (SyncResult) => void from Function '_onDone@118025363':.
INFO|2023-06-27 04:42:55.427854|SyncService (@smoothalligator)|72717253|Returning serverCommitId 32576 Then in the ./sshnp -f @noblesnowbaboon -t @smoothalligator -s id_ed25519.pub -d docker -h @rv_am
ssh -p 40873 atsign@localhost -i /atsign/.ssh/id_ed25519
...
atsign@8ea01a4b8c7a:~$ ps -a
PID TTY TIME CMD
24 pts/0 00:00:00 bash
26 pts/0 00:00:06 dart:sshnpd
73 pts/1 00:00:00 ps
...
|
cc @gkc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @JeremyTubongbanua
What I did
atSignIsActivated
sshnp
atSign does not existsshnpd
atSign does not existFixes issue #118
closes #188