I was unclear in my previous message.
$keys= array();
foreach ($users as $id){
$wpuser = get_user_by( ‘ID’, $id );
$key = $wp_user->pgp_public_key;
array_push($keys, apply_filters(‘openpgp_key’, $wpuser->pgp_public_key));
}
so now I have an array $keys of a couple public pgp keys in binary.
I want to make a post that each of those users can decrypt.
The ‘encrypt’ method in class WP_OpenPGP says that it will accept an array of keys, but when I invoke it using applyfilters(‘openpgp_encrypt’,$message,$keys),
it doesn’t work. It will work if instead of $keys, I specify one of the keys, $keys[0] for example. But it won’t encrypt over more than one key.
Thank you 🙂
Plugin Author
Meitar
(@meitar)
It’s been long enough that I expected your code to work, but when I took a closer look at the plugin what I see is that your code is not expected to work because what you have is an array of OpenPGP_Message objects, each containing a single key, rather than an array of (presumably) OpenPGP_PublicKeyPacket objects (“simple key packets”). See this comment on the OpenPGP-PHP project’s issue number 41.
However, I don’t think there are currently enough filters implemented in this plugin to do what you want. You can freely use the lower-level OpenPGP-PHP library that this plugin includes, but I’m afraid at the moment this should probably be considered a bug in the filter function’s documentation and/or submitted as a feature enhancement to the plugin’s issue tracker.
If you have the time to patch the plugin, that would be welcome, too.
Thank you for your quick response.
I also thought that it may be due to a problem with the objects in the array. I made arrays of OpenPGP_PublicKeyPackets, which didn’t work either. And then I tried just passing in arrays of binary-key strings, which also didn’t work.
I’ve looked through the lower-level library, and finally posted here because I thought I must be overlooking something.
Thank you for your time– if I figure out a good solution I’ll let you know.
Plugin Author
Meitar
(@meitar)
I made arrays of OpenPGP_PublicKeyPackets, which didn’t work either.
If that fails, it may be a legitimate bug. Or maybe those are the incorrect objects to use for the lower-level library? I’m not sure.
Thank you for your time– if I figure out a good solution I’ll let you know.
Thanks, please do!