Very cool.
I was initially surprised that the demo application and launcher is NodeJS, not Rust. But I guess that’s explained at least partially by the difficulty of doing GUI in Rust.
The auth GET ( line 181 ) does return a nice 200, so I guess my handling of the token is fine.
Is the “Content-Type: text/plain” header mandatory ? I wonder if it could be because of not including it, but I don’t see it in the launcher code, and its not in the nodejs example either. GitHub - alexcrichton/curl-rust: Rust bindings to libcurl doesn’t seem to want to send more than one header field.
I guess you can add multiple headers in the code that you have linked. I am not able to get your code compiled on my windows machine (curl-sys fails).
Can you please try adding .header("Content-Type", "text/plain") after line 227 in your code. It is supporting chained syntax, my guess should work hopefully.
yes, I did try with both as per Krishna_Kumar suggestion, but it seems to not change anything.
Right now I am trying to make sure what I am sending. I wish the laucher would be a bit more verbose
@nice - Please do not create directories with metadata right now…there are issues, ref: Log in with Atlassian account but that doesn’t explain the 401. The error could be several things, I have not debugged a ton. One of the things to review is make sure your shared key and nonce extraction appear right. Can you get a sniff of the HTTP traffic exactly?
I am not sure I am sending the correct body, though. From what I understand in the API example and SAFE rust nfs example , I have to :
-serialize the payload structure as a JSON
-change it to bytes
-encrypt the bytes with sodiumoxide
-encode the encrypted bytes as a base64 string
-send this in a POST request to http://localhost:8100/nfs/directory, with the correct headers
-make a prayer
I can only speculate. 401’s are a result of a bad auth header or even failed decryption in a catch all it appears. I can only speculate that the shared key and nonce being used are not extracted right somehow. But I’m afraid you’ll only know where it breaks if you compile the launcher yourself and debug. You can use other clients listed at SAFE API Client Libraries (Go, Ruby, ...) (and even use their shared keys yourself) to test on your end as well.
Maybe a crypto_box versus crypto_box_easy distinction? I had some trouble with that in Python (edit: unlikely, as you manage to open the first box).
Also are you sure this is correct:
for it in vec_decrypted_symm_key_nonce.iter().take(sodiumoxide::crypto::secretbox::NONCEBYTES).enumerate() {
symm_nonce.0[it.0] = *it.1;
}
for it in vec_decrypted_symm_key_nonce.iter().skip(sodiumoxide::crypto::secretbox::NONCEBYTES).enumerate() {
symm_key.0[it.0] = *it.1;
}
for it in vec_decrypted_symm_key_nonce.iter().take(sodiumoxide::crypto::secretbox::KEYBYTES).enumerate() {
symm_key.0[it.0] = *it.1;
}
for it in vec_decrypted_symm_key_nonce.iter().skip(sodiumoxide::crypto::secretbox::KEYBYTES).enumerate() {
symm_nonce.0[it.0] = *it.1;
}