-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Enigma: Cannot delete key pair with authorization subkey. #6381
Comments
What Roundcube/Enigma version? What gpg version? Could you enable enigma_debug and provide the log? |
Server gpg (From armored mail header): Roundcube: Enigma (from composer.json): enigma_debug: enigma.txt |
GnuPG 2.0 is not the best version to use. 1.4 or 2.1 is much better. The log does not reveal much unfortunately. It looks like the code does not recognize that the subkey is not public and uses --delete-key instead of --delete-secret-key. How did you generate the keypair? Could you share your keyring for testing? |
Generated with my personal computer by CentOS 7 has 2.0 listed as the latest version, so no 2.1 yet. Nothing before that either. |
I was unable to reproduce the issue with your keyring on gnupg 2.1.15. Anyway, I think I know how we can workaround this issue. We could fallback to --delete-secret-key if --delete-key fails and vice versa. |
I have another idea. Could you check this patch? --- a/plugins/enigma/lib/enigma_driver_gnupg.php
+++ b/plugins/enigma/lib/enigma_driver_gnupg.php
@@ -390,8 +390,10 @@ class enigma_driver_gnupg extends enigma_driver
else if ($code == enigma_error::DELKEY) {
$key = $this->get_key($keyid);
for ($i = count($key->subkeys) - 1; $i >= 0; $i--) {
- $type = ($key->subkeys[$i]->usage & enigma_key::CAN_ENCRYPT) ? 'priv' : 'pub';
- $result = $this->{'delete_' . $type . 'key'}($key->subkeys[$i]->id);
+ $subkey = $key->subkeys[$i];
+ $is_priv = ($subkey->usage & enigma_key::CAN_ENCRYPT) || ($subkey->usage & enigma_key::CAN_AUTHENTICATE);
+ $type = $is_priv ? 'priv' : 'pub';
+ $result = $this->{'delete_' . $type . 'key'}($subkey->id);
if ($result !== true) {
break;
}
|
No success. Generated keypairs work fine but my normal still fails to delete. |
Reading into that does make me realize one key (no pun intended) difference between my normal keypair and testing keypair. Normal keypair had a separate subkey for authorization, testing didn't. Note: running tests again, just to double check. |
Yeah, I think that subkey makes the difference, so it would be nice to test that scenario. |
Well, keyring.txt already contains an auth subkey. Pass "TestKeyRing". As expected, once imported it can't be deleted. |
Thanks, I don't understand why yet, but I can at least reproduce the issue now. |
Fixed. |
While trying to delete my existing key pair (part of going through #6380), I'm given a "Unable to delete selected keys" message. Further checking into the logs shows this line:
<n8ht9n3c> PHP Error: Enigma plugin: Private key must be deleted before public key can be deleted. in /srv/www/html/plugins/enigma/lib/enigma_engine.php on line 1049 (POST /?_task=settings&_action=plugin.enigmakeys)
I'm not given an option to remove them separately, and since adding a public and a private automatically consolidates them into a key pair, I'm forced to manually remove the keys from the Enigma keyrings in order to delete a key pair.
The text was updated successfully, but these errors were encountered: