-
Notifications
You must be signed in to change notification settings - Fork 45
Attach pubkey when signing #39
Comments
i worked on this and i have just completed the initial implementation. can you review: and let me know your thoughts and whether should i make any changes or/and submit a pull request. thanks. |
Merged your commit, removed the $dbg declaration and renamed signature.asc->pubkey.asc If you could find a quick way to name the attachment with the actual pubkey ID, like "pubkey_XXX.asc" that'd be even prettier, and more user friendly for users quickly filling t heir downloads directory with "pubkey.asc (1)", "pubkey.asc (2)" and so forth. Surely it can be passed as an arg. I consider the function part to be fixed though, thanks a bunch :-) |
what do you want the XXX to be? i can probably use the key id or the user's email address. maybe we should also have some kind of option "attach public key when signing [yes/no]", although i guess it's better to have fewer settings for the user to take care of. public key can be removed before sending the message anyway. |
yeah, just read your message again and noticed the answer to my question. i'm not sure how can i easily get the key id in php (in the handler for the message_compose hook) since the key is stored locally on the user's computer. i made some changes to have something like pubkey_[username].asc. i'll commit it and wait for your thoughts. |
i might have found a better way to rename the attachment. i'll let you know as soon as possible. |
No stress :-) |
I'd really like that, but with a default of "no". Unless I'm missing something, the whole point of signing an email is that the receiver can verify the signature with the public key he already has (ideally from a known source and transferred out-of-band). My reasoning is this: Just my $0.02, please correct me if mistaken :-) |
default no is easier (as proven by the sign/encrypt options) :-) you are right in your reasoning. in real life people do exchange keys via e-mail though... i guess the key may be used for the other party to send back an encrypted message too. if the other party is careful not to reply to a wrong address, the worst that happens is that the recipient is not able to decrypt the message. anyway, i actually wanted to say that i found a hack to rename the attachment to pubkey_keyid.asc. see: |
Sure, but I don't see much sense in sending the key with every signed message... that's all :-) |
any comments on my "rename public key attachment" above? thanks |
Will take a look ASAP |
In the meantime, I had a look at the code and I was wondering what keeps us from leveraging the built-in upload routines of Roundcube, so there is no custom server-side code needed for this at all. We could build an Ajax request like this one in order to simulate a regular file upload: // Build the payload
var payload = [
'------foobar',
'Content-Disposition: form-data; name="_token"',
'',
rcmail.env.request_token,
'------foobar',
'Content-Disposition: form-data; name="_attachments[]"; filename="here_goes_the_file_name.asc"',
'Content-Type: text/plain',
'',
'Here be the file contents',
'------foobar--'
];
// Let Roundcube build the URL
var url = rcmail.url('upload', { _id:rcmail.env.compose_id || '', _uploadid: new Date().getTime() })
// Submit the request
$.ajax({
type: 'post',
url: url,
contentType: 'multipart/form-data; boundary=----foobar',
data: payload.join('\n'),
success: function(data) {
// Extract the add2attachment_list statement from the response
var statement = data.match(/rcmail\.add2attachment_list\(.+?\);/);
if(statement) {
// eval() is bad, so maybe better parse the original add2attachment_list statement and build one ourselves...
eval(statement[0]);
}
}
}); Of course it still needs some refinement and proper error handling etc. But basically it works. |
I would prefer doing it entirely in JS, concerning as much as possible regarding this plugin actually. But for now let's use bogde's already finished code so we can reach some sort of stable release and then we can improve later. @bogde: Sorry for slow attention, I haven't forgot about this :-) |
Okay, then how about this: I will...
|
May I ask, how about this? |
Add the pubkey file[1] as an attachment to signed emails.
[1] "data:asc," + encodeURIComponent(openpgp.keyring.publicKeys[i].armored)
The text was updated successfully, but these errors were encountered: