It's a known issue that the password will be set to silly value, most likely 'yes'.
You should generate the user key during provisioning with `doveadm cryptokey generate -Uu user -n password`.
Aki
On 08/12/2019 16:22 uxqex4e...@elude.in wrote:
Technically creating and encrypting folder key does notrequire decrypting user's private key. All folder keysare encrypted with user's public key.Problem is for that this is a new user. The new user has no private key. Ineed for generating that private key. It do not the sense encryptssomething using a key public if there is no private key. Both key publicand private is mathematically related and have to be created together. Iam using the wrong command for creating the main user encrypted EC privatekey?
Directing my question primary: it is any way to have the dovecot executesa bash script in the time of the mailbox created (lda_mailbox_autocreate)?
Also, I notice extra behavior when I do:
1. I creates user in mysql database2. I confirms it not exists mailbox for user3. I confirms it not exists cryptokeys for user
root@localhost:/var/vmail# doveadm mailbox cryptokey list -u newuser -UFolder Active Public IDroot@localhost:/var/vmail#4. Before create mailbox or cryptokeys for user, I send mail from existuser to new user5. Postfix Delivers mail to dovecot6. The dovecot accepts mail for new user and create mailbox automatically(lda_mailbox_autocreate)7. I check and see that dovecot creates key of user
root@localhost:/var/vmail# doveadm mailbox cryptokey list -u newuser -UFolder Active Public IDyes XYZroot@localhost:/var/vmail#How the possible??? I have put in settings of mail-crypt that keys of userhave to be encrypted (mail_crypt_require_encrypted_user_key = yes), but Isupply no key! How the dovecot creates main user encrypted public/privateEC keypair without key of encryption given?
I confirm that element of post for 'newuser' is encrypted, but of course Ican no decrypt the mail. I achieve error:
dovecot: imap(newuser...Error: Mailbox INBOX: UID=1: read()failed...Private key not available: Cannot decrypt key XYZNo well for executing generateKeys.sh on user first login. What if theuser receives email before first login? How I execute generateKeys.sh oncreate of mailbox and how I do emails incoming without any keypaircreated? For to reject or queue or save unencrypted until I generatekeypair? It possible?
On Sun, December 8, 2019 08:04, Aki Tuomi via dovecot wrote:>
Technically creating and encrypting folder key does not requiredecrypting user's private key. All folder keys are encrypted with user'spublic key.>>>Aki>On 08/12/2019 09:42 uxqex4efpu--- via dovecot <wrote:>>>>>>>What it is way most best for causing bash script run (as root) of time>mailbox created (lda_mailbox_autocreate)?>>>I use dovecot 2.3.4.1 in Debian 10.>>>>And I use of mail-crypt-plugin>>>>>I setup mail-crypt for requiring user encrypted EC key>(mail_crypt_require_encrypted_user_key = yes). I want for passphrase>encrypt EC key using client plaintext password. There is credential nostored on server. But for user with use password too bad, I concatenateuser plaintext password with random salt. And then string to SHA512()hashand use as decryption key (mail_crypt_private_password) for EC privatekey.>>>For above I have plugin config>>>>mail_plugins = $mail_plugins mail_cryptplugin {mail_crypt_curve = secp256k1mail_crypt_require_encrypted_user_key = yesmail_crypt_save_version = 2}>And for returning userdb_mail_crypt_private_password, I have sql query>>>>password_query = SELECT username, password, \SHA2( CONCAT('%w',salt), 512 ) AS userdb_mail_crypt_private_password \>FROM virtual_users WHERE username='%u';>But how I generate key of user automatically? Note for generating key of>user, I need user password plaintext. I never save plaintext password ofuser of the server.>>>Also user of note creates in PHP of web of the server. And for security I>do not allow PHP exec shell (php.ini disabled_functions). Definitely notleaving PHP doveadm access!>>>For solving subject to generate user key encrypted, I do imap of call of>the service 'imap-postlogin' the service likes document "Post-loginscripting' write>>>>And 'imap-postlogin' execute my custom script with 'script-login' binary>3533/src/util/script-login.c>>>>Here it is config for above>>>>service imap {executable = imap imap-postlogin}>service imap-postlogin {executable = script-login /usr/local/bin/generateKeys.shunix_listener imap-postlogin {}>}>And generateKeys.sh it is script simple for generating keys with sha256()>hash product mysql. Variable of note ${MAIL_CRYPT_PRIVATE_PASSWORD}automatically put of 'userdb_mail_crypt_private_password' return of mysql>field of query when documenteddings>>>Fields returned by userdb lookup with their keys uppercased>(e.g. if userdb returned home, it's stored in HOME).>Here generatekeys.sh>>>>#!/bin/bash>if [ `/usr/bin/doveadm mailbox cryptokey list -u "${USER}" -U >/dev/null | wc -l` -lt 2 ]; then>/usr/bin/doveadm -o>"plugin/mail_crypt_private_password=${MAIL_CRYPT_PRIVATE_PASSWORD}">mailbox cryptokey generate -u "${USER}" -U > /dev/nullfiexec "$@"This work! But I want more good. By why execute each login? Possible has>generateKeys.sh execute in the times only of dovecot create mailbox(lda_mailbox_autocreate) instead?>>>---Aki Tuomi>>
--- Aki Tuomi