Search code examples
phpgnupgpecl

How can I handle/see Private Keys in php gnupg?


I'm using the gnupg pecl Extension for PHP, and want to build a simple keymanger. Import Public as well as Private keys is working. But getting info about them seems to be broken, or there are some additional options that I can't find. The keyinfo method

$gnupg->keyinfo('');

returns a list where every key is listed as a public key. And always marked with "can_sign = true", even if there was never a Private key imported. If I import one public key, and another private key for a different uid. I get 2 keys listed, both as public, and both as can_sign.

How can I see which key is Private, and how can I see if a key can really be used for signing?

I have attached a where the Key on position 0 is only public, and the key on position 2 is only private.
Even if I import the Private AND the public key, I see only one public key for them.

The Key on position 0 is only public, and the key on position 2 is only private.


Solution

  • This is a Bug in the PECL gnupg Extension. Known since 2016, fixed in their code, but as of October 2019 no release with that fix. https://github.com/php-gnupg/php-gnupg/issues/5