ruby-gpgme
ruby-gpgme copied to clipboard
Key Management
How do I remove a key from the keychain (or purge the keychain)? My current flow is:
User enters password in rails UI, the sidekiq worker does something like GPGME::Key.import(File.open("#{user_id}.ppk"))
.
I am able to decrypt data, however, when the worker is done, I can decrypt data with any password as that key is in memory. I need to remove that key from the keychain the valid password for that key is required to decrypt data again.
It sounds like the gpg agent might have cached the password. Check out https://unix.stackexchange.com/questions/395875/gpg-does-not-ask-for-password particularly setting up ~/.gnupg/gpg-agent.conf for the sidekiq user (if different that www-data) and pkill gpg-agent to ensure the settings are reloaded. I think setting the cache-ttl settings should help you.