S/MIME certificate import stores Common Name instead of email address, causing decryption failure
Maintainers usually reply within 1 day
@kesselb is already working on this.
Since Jul 29, 2026.
Assessment
This issue has not been assessed yet.
Description
Steps to reproduce
- Import a valid S/MIME certificate (including the private key) in Nextcloud Mail.
- Receive an encrypted S/MIME message (Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data).
- Open the message.
- The message cannot be decrypted and Mail returns:
Failed to find a suitable S/MIME certificate for decryption - After investigating the database, the imported certificate is stored with the certificate Common Name in the "email_address" field instead of the recipient email address.
Example:
email_address = "[EG] F12013577 RI-C16 0001"
instead of
email_address = "[email protected]" - Updating the "email_address" field to the actual recipient email immediately fixes the issue without any other changes.
Expected behavior
The imported S/MIME certificate should store the recipient email address (RFC822Name / emailAddress) instead of the certificate Common Name.
After importing the certificate, Mail should automatically find the correct certificate and decrypt encrypted S/MIME messages without requiring any manual database changes.
Actual behavior
After importing a valid S/MIME certificate (including the private key), encrypted S/MIME messages cannot be decrypted.
Mail returns:
Failed to find a suitable S/MIME certificate for decryption
The server log contains:
OCA\Mail\Exception\SmimeDecryptException:
Failed to find a suitable S/MIME certificate for decryption
After investigating the database, I found that the imported certificate is stored with the certificate Common Name in the "email_address" field instead of the actual recipient email address.
Example:
email_address = "[EG] F12013577 RI-C16 0001"
instead of
email_address = "[email protected]"
Updating this field manually immediately fixes the issue. S/MIME decryption works correctly without any other changes.
The affected certificate is issued by Banco de España and contains a private key. The same certificate decrypts the same messages correctly in SnappyMail, so the certificate itself appears to be valid.
Only the signature verification warning remains.
Mail app version
5.5.17
Nextcloud version
30.0.17.2
Mailserver or service
Dovecot IMAP
Operating system
Ubuntu 24.04
PHP engine version
PHP 8.3
Nextcloud memory caching
memcache.local
Web server
Apache (supported)
Database
MariaDB
Additional info
No response
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 364
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 100
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/mail
-
1. to develop enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
nextcloud/mail#13841 · 3 comments ·
Maintainers usually reply within 1 day
-
1. to develop enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
nextcloud/mail#13828 · 1 comment ·
Maintainers usually reply within 1 day
-
Show email next to name in Search dropdownPossibly taken @vansh-nagar claimed this 23 days ago. Open1. to develop enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
nextcloud/mail#13703 · 1 comment ·
Maintainers usually reply within 1 day
-
ISO-2022-JP emails are garbled in Mail 5.10.12 [Minimal fix available]Possibly taken @neconohitomi claimed this 43 days ago. Open1. to develop bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
nextcloud/mail#13472 · 1 comment ·
Maintainers usually reply within 1 day
-
1. to develop technical debt
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
Similar issues
-
documentation good first issue theming
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
drevendev/PatchPitch#2 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
521xueweihan/HelloGitHub#4025 ·