# DeltaChat fails to import keys

**URL:** <https://support.delta.chat/t/deltachat-fails-to-import-keys/2592>\
**Category:** Mutual Help\
**Tags:** android\
**Created:** [May 29, 2023, 5:47pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592 "2023-05-29T17:47:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcrass](https://support.delta.chat/user_avatar/support.delta.chat/tcrass/32/1817_2.png) [@tcrass](https://support.delta.chat/u/tcrass)\
**Post date:** [May 29, 2023, 5:47pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/1 "2023-05-29T17:47:58Z")

</div>

**Delta Chat version**

1.36.5

**Expected behavior**

Some time ago, I exported keys from DeltaChat running on an Android device and copied them over to my PC using `adb pull`. Using `adb push`, I now copied them over to a new Android device into the directory suggested by DetaChat’s “Import secret key” dialog and verified their presence as well as file permissions using `adb shell`:

```auto
payton:/storage/emulated/0/Download $ ls -l
total 8
-rw-rw---- 1 root everybody 3498 2020-01-12 09:43 private-key-1.asc
-rw-rw---- 1 root everybody 1733 2020-01-12 09:43 public-key-1.asc

```

When in the “Import secret key” dialog I tap [OK], I expect the key files to get successfully imported.

**Actual behavior**

After tapping [OK], I get a message saying “IMEX failed to compete: No private keys found in ‘/storage/emulated/0/Download’.”

**Steps to reproduce the problem**

Described above.

**Debug logs**

```auto
05-29 19:43:57.690 I/DeltaChat(16335): src/scheduler.rs:82: stopping IO
05-29 19:43:57.695 I/DeltaChat(16335): src/scheduler.rs:345: shutting down inbox loop
05-29 19:43:57.695 I/DeltaChat(16335): src/scheduler.rs:552: shutting down simple loop
05-29 19:43:57.695 I/DeltaChat(16335): src/scheduler.rs:633: shutting down smtp loop
05-29 19:43:57.701 I/DeltaChat(16335): src/scheduler.rs:82: stopping IO
05-29 19:43:57.701 I/DeltaChat(16335): src/imex.rs:379: Import/export dir: /storage/emulated/0/Download
05-29 19:43:57.713 E/DeltaChat(16335): IMEX failed to complete: No private keys found in "/storage/emulated/0/Download".
05-29 19:43:57.713 W/DeltaChat(16335): deltachat-ffi/src/lib.rs:2192: IMEX failed: No private keys found in "/storage/emulated/0
/Download".
05-29 19:43:57.754 I/DeltaChat(16335): src/scheduler.rs:60: starting IO
05-29 19:43:57.754 I/DeltaChat(16335): src/scheduler.rs:252: starting inbox loop
05-29 19:43:57.754 I/DeltaChat(16335): src/job.rs:264: Loading job.
05-29 19:43:57.754 I/DeltaChat(16335): src/scheduler.rs:529: starting simple loop for Mvbox
05-29 19:43:57.754 I/DeltaChat(16335): src/imap.rs:309: Connecting to IMAP server
05-29 19:43:57.754 I/DeltaChat(16335): src/scheduler.rs:561: starting smtp loop
05-29 19:43:57.757 I/DeltaChat(16335): src/ephemeral.rs:565: Ephemeral loop waiting for deletion in 24h 0m 0s or interrupt
05-29 19:43:57.759 I/DeltaChat(16335): src/imap.rs:309: Connecting to IMAP server
05-29 19:43:57.760 I/DeltaChat(16335): src/scheduler.rs:724: scheduler is running
05-29 19:43:57.760 I/DeltaChat(16335): src/location.rs:654: Location loop is waiting for 24h 0m 0s or interrupt
05-29 19:43:57.762 I/DeltaChat(16335): src/smtp.rs:754: Sending MDNs
05-29 19:43:57.762 I/DeltaChat(16335): src/contact.rs:1609: Recently seen loop waiting for 24h 0m 0s or interrupt
05-29 19:43:57.764 I/DeltaChat(16335): src/scheduler.rs:600: smtp fake idle - started
05-29 19:43:57.764 I/DeltaChat(16335): src/scheduler.rs:622: smtp has no messages to retry, waiting for interrupt
05-29 19:43:57.774 I/DeltaChat(16335): src/net.rs:70: Resolved <some.mail.server>:993 into [2a01:488:42:1000:b24d:51f1:
c9:16d9]:993.
05-29 19:43:57.774 I/DeltaChat(16335): src/net.rs:70: Resolved <some.mail.server>:993 into 178.77.81.241:993.
05-29 19:43:57.777 I/DeltaChat(16335): src/net.rs:70: Resolved <some.mail.server>:993 into [2a01:488:42:1000:b24d:51f1:
c9:16d9]:993.
05-29 19:43:57.778 I/DeltaChat(16335): src/net.rs:70: Resolved <some.mail.server>:993 into 178.77.81.241:993.
05-29 19:43:57.926 I/DeltaChat(16335): src/imap.rs:378: Logging into IMAP server with LOGIN
05-29 19:43:57.968 I/DeltaChat(16335): src/imap.rs:378: Logging into IMAP server with LOGIN
05-29 19:43:57.988 I/DeltaChat(16335): src/imap.rs:394: Successfully logged into IMAP server
05-29 19:43:58.008 I/DeltaChat(16335): src/imap.rs:720: No new emails in folder DeltaChat
05-29 19:43:58.025 I/DeltaChat(16335): src/scheduler.rs:493: IMAP session supports IDLE, using it.
05-29 19:43:58.027 I/DeltaChat(16335): src/imap.rs:394: Successfully logged into IMAP server
05-29 19:43:58.042 I/DeltaChat(16335): src/imap/idle.rs:59: DeltaChat: Idle entering wait-on-remote state
05-29 19:43:58.046 I/DeltaChat(16335): src/imap.rs:720: No new emails in folder INBOX
05-29 19:43:58.067 I/DeltaChat(16335): src/scheduler.rs:493: IMAP session supports IDLE, using it.
05-29 19:43:58.082 I/DeltaChat(16335): src/imap/idle.rs:59: INBOX: Idle entering wait-on-remote state

```

---

<div class="post-metadata">

**Author:** ![link2xt](https://support.delta.chat/user_avatar/support.delta.chat/link2xt/32/1971_2.png) [@link2xt](https://support.delta.chat/u/link2xt)\
**Post date:** [May 29, 2023, 6:10pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/2 "2023-05-29T18:10:06Z")

</div>

This looks like a permission problem to me. The code which looks through the directory is here, and it should at least output the “considering key file” log:

> <https://github.com/deltachat/deltachat-core-rust/blob/5b435d11c72495ff2fbde60af7a0795b33757e16/src/imex.rs#L605-L630>

Could you check if the application has the permission to read the storage? Maybe you denied it when it was requested?

---

<div class="post-metadata">

**Author:** ![tcrass](https://support.delta.chat/user_avatar/support.delta.chat/tcrass/32/1817_2.png) [@tcrass](https://support.delta.chat/u/tcrass)\
**Post date:** [May 29, 2023, 6:27pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/3 "2023-05-29T18:27:46Z")

</div>

Hm, I can’t remember being asked for any permissions when installing DeltaChat on the new device (which runs LineageOS 20). When checking DeltaChat permissions in the “Apps” category of the system settings, I find permissions for reading audio, video and image files, but no general permission of reading the storage. Or is there any other permissions settings page somewhere hidden in the system settings which I have overlooked?

BTW, DeltaChat is capable of _exporting_ the keys in to the mentioned location, so write permissions seem to be granted.

---

<div class="post-metadata">

**Author:** ![dctopo](https://support.delta.chat/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@dctopo](https://support.delta.chat/u/dctopo)\
**Post date:** [August 29, 2023, 4:08pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/4 "2023-08-29T16:08:28Z")

</div>

Hi, maybe it is of interest what I figured out as a workaround [here](https://support.delta.chat/t/how-to-recover-all-chats-after-dc-reinstallation/2686/13). I had the same situation, that DeltaChat fails to import keys. I am on Android 11 (LineageOS 18.1) and it looks like a very odd permission problem…

---

<div class="post-metadata">

**Author:** ![link2xt](https://support.delta.chat/user_avatar/support.delta.chat/link2xt/32/1971_2.png) [@link2xt](https://support.delta.chat/u/link2xt)\
**Post date:** [September 1, 2023, 1:03pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/5 "2023-09-01T13:03:07Z")

</div>

Maybe we should export both private and public key to a single file. Selecting a file on Android and similarly sandboxed platforms like Flatpak seems to be much less error-prone than selecting a folder, there are no failures like “granted access to the folder but not the files inside of it” possible.

`gpg` itself does not allow to use both `--export` and `--export-secret-keys` though, so having such file with both keys concatenated is probably not common.

Maybe it is possible to drop the public key and reconstruct it from the private key, then there is no need to import/export the public key at all, or only allow to export it for publishing somewhere?

EDIT: [Information Security Stack Exchange question](https://security.stackexchange.com/questions/243959/what-is-the-correct-way-to-create-a-backup-copy-of-a-pgp-key-pair) suggests that private key export contains the public key as well. So exporting public key should not be necessary to transfer  
And the import function in the core only needs the secret key file, because it extracts the public key from the secret key:

> <https://github.com/deltachat/deltachat-core-rust/blob/4a0585404a0a5f2e3edb4257a69d63efeb199ef3/src/imex.rs#L594-L650>

EDIT2: I made a PR to stop using public keys in the tests: [refactor: ignore public key argument in dc\_preconfigure\_keypair() by link2xt · Pull Request #4701 · deltachat/deltachat-core-rust · GitHub](https://github.com/deltachat/deltachat-core-rust/pull/4701)  
If this works out, we can do the same for import/export and import/export a single “secret” file, thus not dealing with the directories anymore.

---

<div class="post-metadata">

**Author:** ![link2xt](https://support.delta.chat/user_avatar/support.delta.chat/link2xt/32/1971_2.png) [@link2xt](https://support.delta.chat/u/link2xt)\
**Post date:** [September 18, 2023, 9:09pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/6 "2023-09-18T21:09:19Z")

</div>

Note: there is a similar issue in the desktop repository, the requirement to select a directory rather than a file is confusing:

> <https://github.com/deltachat/deltachat-desktop/issues/1863>
>
> \- Operating System (Linux/Mac/Windows/iOS/Android): Ubuntu 20.04
> \- Delta Chat V…ersion: 1.12.0
> \- Expected behavior: I should be able to select the keys to import.
> \- Actual behavior: When I am provided the file selection dialog, I can see my keys in my home directory, they are readable by me, but they are 'greyed out', so I cannot select them. 
> \- Steps to reproduce the problem: Settings-\>Import Secret Keys
> \- Screenshots: I can not figure out how to add an image to an issue in github. I'm not using a window manager that has 'drag and drop', and I see no file picker here :(

Going to make a fix for the core to be able to open a file with a secret key directly, this may not only fix the Android permission problem but be a better UI for the desktop.

---

<div class="post-metadata">

**Author:** ![adbenitez](https://support.delta.chat/user_avatar/support.delta.chat/adbenitez/32/2323_2.png) [@adbenitez](https://support.delta.chat/u/adbenitez)\
**Post date:** [September 29, 2023, 5:04pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/7 "2023-09-29T17:04:49Z")

</div>

android fix:

> <https://github.com/deltachat/deltachat-android/pull/2681>
>
> close #2658

---

<div class="post-metadata">

**Author:** ![adbenitez](https://support.delta.chat/user_avatar/support.delta.chat/adbenitez/32/2323_2.png) [@adbenitez](https://support.delta.chat/u/adbenitez)\
**Post date:** [September 29, 2023, 5:08pm UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/8 "2023-09-29T17:08:42Z")

</div>

desktop fix:

> <https://github.com/deltachat/deltachat-desktop/pull/3420>
>
> fixes #1863

---

<div class="post-metadata">

**Author:** ![r10s](https://support.delta.chat/user_avatar/support.delta.chat/r10s/32/1513_2.png) [@r10s](https://support.delta.chat/u/r10s)\
**Post date:** [February 21, 2026, 11:54am UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/9 "2026-02-21T11:54:46Z")

</div>

Closing as now longer relevant.

The mentioned option does no longer exist; Delta Chat does all the key handling for you, we do not ask user or expect them to understand anything on that level of detail.

> **[Delta Chat: Delta Chat V2: a major security upgrade, beautified contact...](https://delta.chat/en/2025-08-04-encryption-v2)**
>
> With Delta Chat Version 2, chats are end-to-end encrypted, always and by default. Previously it was possible that chats without green checkmarks could contain messages without end-to-end encryption...

for casual readers: do not worry: just use Delta Chat as any other messenger, the onboarding is one of the simplest one out there: **just enter your name**

---

<div class="post-metadata">

**Author:** ![r10s](https://support.delta.chat/user_avatar/support.delta.chat/r10s/32/1513_2.png) [@r10s](https://support.delta.chat/u/r10s)\
**Post date:** [February 21, 2026, 11:54am UTC](https://support.delta.chat/t/deltachat-fails-to-import-keys/2592/10 "2026-02-21T11:54:50Z")

</div>


