Skip to content
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

Made library compatible with both Unix and Windows versions of gpg-agent #3

Merged
merged 1 commit into from
May 9, 2018

Conversation

mhenderson-so
Copy link
Contributor

Honestly this took me about an hour to do this morning, so it might need a bit more looking over. But essentially this adds support for Windows gpg-agent into this library.

I added the support by using compile-time flags in gpgagent_unix.go and gpgagent_windows.go so that a different version of NewGpgAgentConn gets compiled in depending on which platform you compile with.

Because Windows does not have Unix sockets, and gpg-agent doesn't use named pipes (rather it binds a localhost TCP socket), the Windows version:

  • Discovers the path to the socket file (environment variables are not reliable on Windows)
  • Opens the socket file
  • Reads the port number and the nonce out of the socket file
  • Initiates a TCP connection instead of a Unix connection to 127.0.0.1:port
  • Writes the nonce to the port
  • Returns the TCP socket

I've only done limited testing, but it works great in the examples I've tried.

@jcmdev0
Copy link
Owner

jcmdev0 commented May 9, 2018

Might be worth separating the parsing for some unit tests, but for the sake of advancing the code I forked out of another project for isolation, this is great =).

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants