neuhalje / bouncy-gpg

Make using Bouncy Castle with OpenPGP fun again!
https://neuhalje.github.io/bouncy-gpg/
Other
205 stars 58 forks source link

Not null requirement for Keyring Config #37

Closed mkmeral closed 4 years ago

mkmeral commented 4 years ago

Keyring config requires private key public key and password to be not null, even when they are not used. For example, even to only encrypt with public key (not signing) it requires those to be non null. Current workaround I found is to give empty string for password and random file for private key (because it creates an input stream from file).

The problem I specifically have is at (public class Rfc4880KeySelectionStrategy implements KeySelectionStrategy:137) and the reason it gives an error is, it tries to get secret keyrings before checking what the purpose is, So a simple solution for this specific problem would be to move line 137 inside the switch statement. However, I don't have extended knowledge of this project, so I am not sure if that is the optimal solution

neuhalje commented 4 years ago

@mkmeral : Working on it. Is there a specific reason why you use the FileBasedKeyringConfig? I strongly recommend to switch to InMemoryKeyring because it is not dependend on gpg internals.

See here for more reasons to do so.

neuhalje commented 4 years ago

I moved getSecretKeyRings into the conditional in commit aa35a82

Can you test with the version in GitHub?

neuhalje commented 4 years ago

Or with 2.2.0

mkmeral commented 4 years ago

@neuhalje : Yeah, I have later changed it to InMemoryKeyring, and I am using it like that right now. I won't be able to test it right now, since that would require for me to revert commits. I will be able to test probably in 2 weeks, I will write back on the results.

neuhalje commented 4 years ago

Since InMemoryKeyring is the future I am inclined to close this