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

GnuPGContext won't find my public certificate (Mac OS X, GPGTools) #194

Closed
polterguy opened this issue Dec 8, 2015 · 16 comments
Closed
Labels
bug Something isn't working

Comments

@polterguy
Copy link

Howdy,

I've installed GPGTools on my MacBook Air, and subclassed GnuPGContext, supplying my password in the GetPasswordForKey method, but when I invoke MultipartEncrypted.Encrypt, it throws an exception saying; "MimeKit.Cryptography.PublicKeyNotFoundException
The public key could not be found."

Stack trace is;
at MimeKit.Cryptography.OpenPgpContext.GetPublicKey (MimeKit.MailboxAddress mailbox) [0x000ea] in :0
at MimeKit.Cryptography.OpenPgpContext.GetPublicKeys (IEnumerable1 mailboxes) [0x00024] in <filename unknown>:0 at MimeKit.Cryptography.OpenPgpContext.Encrypt (IEnumerable1 recipients, System.IO.Stream content) [0x0001c] in :0
at MimeKit.Cryptography.MultipartEncrypted.Encrypt (MimeKit.Cryptography.OpenPgpContext ctx, IEnumerable`1 recipients, MimeKit.MimeEntity entity) [0x0009a] in :0

I have triple checked in GPG Keychain from GPGTools that the email address is correct. I have even tried multiple emails, both that are imported from Keychain server, and locally created, but regardless of what I do, it seems to choke ...

I installed GPGTools with all default settings, and from a Terminal window "gpg" is a recognized command, and starts the gpg process from GnuPG.

Suggestions ...?

PS,
Code is exact replica (more or less) of your sample code of how to encrypt message using PGP in a GnuPG subclassed context from your README.md file ...

@jstedfast
Copy link
Owner

I wonder if GPGTools puts the keyrings in a different place than gpg does when installing it via homebrew.

@jstedfast
Copy link
Owner

Looks like it's stored in the same place, so that's not the problem.

Does the email address you are trying to encrypt to exist in your keyring?

@jstedfast
Copy link
Owner

BTW, which target framework are you using? Are you using the PCL? Or .NET 4.5? If you are using nuget, you can check your packages.config to be sure.

@polterguy
Copy link
Author

Hi Jeff, and thanx for blistering fast answers, as usual :)

The email I am sending to, and also using to encrypt my message, is the same, and it exist in my GPG Keychain, when I look in the GUI for GPG Keychain. I am using .NET 4.5

package id="MailKit" version="1.2.15" targetFramework="net45"
package id="MimeKit" version="1.2.16.0" targetFramework="net45"

(from my packages.config file)

@polterguy
Copy link
Author

BTW, it's a web app, running (I presume) in xsp4 (Xamarin) ...

@jstedfast
Copy link
Owner

Okay... and I assume that the key has not been revoked. Does it have an expiration date?

In GPGTools' Keyring app, you can right-click on a key and show details.

On the "Key" tab (the main tab), what are the values of Validity and Capabilities?

On the "Subkeys" tab, what is the value of Capabilities?

I'm not entirely sure how to read these values, but I think the subkey Capability value should be "e" (for "supports encryption").

@jstedfast
Copy link
Owner

(I ask about the expiration date because I am wondering if my logic to calculate expiration is wrong)

@polterguy
Copy link
Author

Expires; 8 December 2019 at 12:19
Validity; Ultimate (I created it locally)
Capabilities; "e"

PS,
I am in Norway, might there be some Localization issues when calculating dates ...?

@jstedfast
Copy link
Owner

Thanks, I'm thinking the expiration date calculation might be the culprit. Everything else matches what my keys look like.

jstedfast added a commit that referenced this issue Dec 8, 2015
@jstedfast
Copy link
Owner

Darn >= instead of <= ;-)

@polterguy
Copy link
Author

Norway use "15 February 2015" for user displayed dates where US use "February 15, 2015", etc ...
Don't know if that's the issue, but hopefully it may help ...

PS!
You saw my comment about this being a Web App, running on xsp4 ...?

Let me know if you need anymore to go on :)

@polterguy
Copy link
Author

Hahahahahahaha :D

ROFLMAO ...!!

Well, glad to please :)

Thx, when will this be out in nuget?

@jstedfast
Copy link
Owner

https://www.nuget.org/packages/MimeKit/1.2.17.3

I normally don't post to nuget this fast, but I wanted to release a stable (non-prerelease) nuget with the fixes I had done recently anyway :-)

@polterguy
Copy link
Author

Thx, you're a champion!! :)

@jstedfast jstedfast added the bug Something isn't working label Dec 8, 2015
@polterguy
Copy link
Author

The Eagle has landed Houston!! 💃

@jstedfast
Copy link
Owner

Fixed in the MimeKit 1.2.18 nuget :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants