Skip to content
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

Keys export import #707

Merged
merged 12 commits into from
Apr 3, 2019
Merged

Keys export import #707

merged 12 commits into from
Apr 3, 2019

Conversation

nicodh
Copy link
Member

@nicodh nicodh commented Mar 1, 2019

continues #474

okdistribute and others added 2 commits February 28, 2019 20:41
Import/Export works but the event DC_EVENT_IMEX_FILE_WRITTEN
is not fired since somehow the export tries twice to write the
file which results in an error:
Cannot delete "/tmp/private-key-default.asc".

So keys are exported but we can't show a confirmation message.
@nicodh nicodh changed the title Keys export import WIP: Keys export import Mar 1, 2019
@nicodh
Copy link
Member Author

nicodh commented Mar 1, 2019

@Karissa mentioned it should ask for the password. But which one? The password for password protected keys?

@okdistribute
Copy link
Contributor

The password to the account which is checked by logging in or checking the config var in the backend. Use an IPC call for this.

@nicodh
Copy link
Member Author

nicodh commented Mar 2, 2019

Hmm, the account password is easily to get from the settings since 4925f93 so this would not really improve security. The android app asks for the PIN (of the phone) when you export the secret keys. But afaik it is not possible to ask for the users OS account password with electron. Might be useful to introduce some PIN/password protection for deltachat desktop but that's another topic...

@Jikstra
Copy link
Contributor

Jikstra commented Mar 4, 2019

Is this really needed to ask for the email password? @r10s @hpk42

@nicodh nicodh changed the title WIP: Keys export import Keys export import Mar 6, 2019
},
"settings_manage_keys": {
"message": "Manage Keys"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use the already translated translation keys? I think they are adequate to the ones here. Maybe some leftovers of the old pr from @Karissa? We now have access to all the translations which we also use on deltachat-android.

  "pref_managekeys_menu_title": {
    "message": "Manage keys"
  },
  "pref_managekeys_ask_for_storage_permission": {
    "message": "Delta Chat needs access to your files to import/export keys."
  },
  "pref_managekeys_export_secret_keys": {
    "message": "Export secret keys"
  },
  "pref_managekeys_export_explain": {
    "message": "Export secret keys to \"%1$s\"?"
  },
  "pref_managekeys_import_secret_keys": {
    "message": "Import secret keys"
  },
  "pref_managekeys_import_explain": {
    "message": "Import secret keys from \"%1$s\"?\n\n• Existing secret keys will not be deleted\n\n• The last imported key will be used as the new default key unless it has the word \"legacy\" in its filename"
  },
  "pref_managekeys_secret_keys_exported_to_x": {
    "message": "Secret keys written successfully to \"%1$s\"."
  },
  "pref_managekeys_secret_keys_imported_from_x": {
    "message": "Secret keys imported from \"%1$s\"."
  },

@nicodh
Copy link
Member Author

nicodh commented Mar 7, 2019

DC_EVENT_IMEX_FILE_WRITTEN should be triggered after keys are exported, but is not...?

@Jikstra
Copy link
Contributor

Jikstra commented Mar 8, 2019

DC_EVENT_IMEX_FILE_WRITTEN should be triggered after keys are exported, but is not...?

Good question. Maybe @r10s can help us on this question.
Exporting seems to work. Importing too, but didn't properly test this. Also not sure how to test that exactly.

@r10s
Copy link
Member

r10s commented Mar 14, 2019

DC_EVENT_IMEX_FILE_WRITTEN should be triggered after keys are exported, but is not...?

it's a bug in core, i'll fix it.

@nicodh
Copy link
Member Author

nicodh commented Mar 15, 2019

So this works fine now with the fix in core. Except the fact that we can't show a success message after having successfully imported keys since there is no event for that. Even if a DC_EVENT_IMEX_FILE_WRITTEN event would be triggered in https://github.com/deltachat/deltachat-core/blob/master/src/dc_imex.c#L706 we couldn't distinguish in the event handler which action triggered it.
At the moment I distinguish export-backup from export-keys just by checking the "bak" ending exists in filename...
https://github.com/deltachat/deltachat-desktop/blob/keys-export-import/src/renderer/ScreenController.js#L70
Which is kind of a hack... ;-)

@r10s
Copy link
Member

r10s commented Mar 15, 2019

it's all about export?

there are the events DC_EVENT_IMEX_PROGRESS - on success 1000 permille will be reported, on failure, it's 0.

in fact, these events do not regard single export failed. i'll change this in the branch.

@nicodh thanks for having a closer look at this :) it is obviously one of the parts that lacks some details :)

@r10s
Copy link
Member

r10s commented Mar 15, 2019

i've updated the branch, DC_EVENT_IMEX_PROGRESS reports success/failure on exporting keys now (same as for backups).

wrt to decide whether the event belongs to a backup or to a key-export (or whatever will be added in the future - location-export?):

there is always only one export/import running at the same time. so, you can just remember the last action started.

@nicodh nicodh merged commit a8a314b into master Apr 3, 2019
@nicodh nicodh deleted the keys-export-import branch April 3, 2019 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants