-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: gpg-agent support #14
base: main
Are you sure you want to change the base?
Conversation
Looking great so far! I did some shallow testing and things seem to work well with gpg-agent. The only thing I noticed is that we fail signing completely if updating the cards fails (here). On my end, this failed because I don't have any hardware devices I could test with (so I tested with my normal keyring). I think we should only print a warning here, specifically for setups which might not be card-based. Let me know when it's ready for review! |
Done. Realistically, storing the key in the agent vs directly in the container makes little to no difference because, with the docker socket exposed, you can always escape to the host with root privileges. Not sure if TPM counts as card-based, will test it tomorrow.
Unless I'm missing something obvious, It should be feature-complete. I suck at making human-readable docs so if you want to do that feel free. I've included the config I'm currently running on my instance in the original PR comment. I will run it like that for a while and make sure it's stable. If you wanna live on the edge and merge it then go ahead, it shouldn't break any existing setups. |
One possible improvement would be to stop any further attempts at signing anything if the password/pin provided is wrong. Many cards will destroy the key material if you enter the wrong pin too many times. Not sure how to best implement this here though. |
Okay, I'll draft something up for the docs. I'll include the things for setup with systemd you have provided, that'll be a good starting point. I don't see any issues in the code or feature wise, so I'll do some last testing on my end and then it'll be ready for merging. I am really busy today, so I'll do it tomorrow morning.
I see, we could track signature failures and refuse to continue after a failure. But judging from the docs, we the pin is only used during the signing process, so I don't know whether we can differentiate the pin being wrong from any other signature failure. I'll have a look tomorrow. Otherwise I'll just add a notice to the docs for now, so people make double sure they don't mistype their password. |
Pretty sure it has a unique error message (after all, any decent frontend will usually prompt the user for a second try if they mistype it). I'm more concerned about how we track this. Putting it in a database seems overkill and hard to reset without extra effort. Storing it in a global variable seems like a decent-ish middle ground. It won't persist across restarts but will usually give the user enough time to figure out something is broken. Edit 2: now that I think about it, gpg is capable of tracking the "tries left" counter. We could probably use that and refuse to sign if it's at 1 |
Okay, I've drafted up something for the docs and pushed it onto this branch. Let me know if I missed something. I've also had a look at the bad passphrase issue. As it stands it's not that straight forward to "detect" a bad passphrase, because the library just shoves the error message from the agent into an "Operation failed" error (see here). I don't know whether these messages are always the same for bad passphrases, for me it always was "Bad passphrase", is this the same for keys on hardware devices? Other than that I've done my testing, and everything works flawlessly, so it would be good to go. |
Sorry for the late response.
It's there but it's not parsed. It's returned as part of the
The part we are interested in is Here is how gpg parses it and here are the descriptions The last 5 numbers of We could either try to upstream the parsing into sequoia or just grab Let me know what you think, I'll try to get this implemented later when I have some time.
Same on my end EDIT: From the doc:
A little 🤓 nitpick here, it's not only needed for picking the right key, but the main reason it's there is that it's impossible to create a valid signature without knowing the full details of the public key. The agent only deals with the private part and the actual crypto. |
I think parsing the relevant parts of
Sure, feel free to rephrase anything in the docs. I'm not too deep in the weeds of pgp myself, so there might be a couple of mistakes. |
WIP: not properly tested, missing doc
decided against using the keystore since it's meant for "normal" environments with a working PGP home, proper certs, default socket paths, depends on several GPG binaries, etc.
Changes:
sign_key.asc
can now also be just the public key (we still need it since the agent only deals with private keys)/app/S.gpg-agent
exists then the agent will be used for cryptographic operations and only the public key portion ofsign_key.asc
will be used.Logic if using the agent:
the agent needs to have loopback pinentry enabled or offer keys without a password.
closes #12
My suggestion for a setup to be included in the docs