Closed felix-exon closed 3 years ago
Hi, it's actually expecting the string value provided to be the key itself, not the path to it. This then gets converted to a stream.
public static PgpPublicKey ReadPublicKey(string publicKey)
{
if (string.IsNullOrEmpty(publicKey))
throw new FileNotFoundException(String.Format("Public key was not provided"));
return ReadPublicKey(publicKey.GetStream());
}
Wow this makes perfect sense. For some reason I expected it to be the path to the file. I am pretty sure this worked before.
It probably did, things have changed behind the scenes a bit. If you want to use the path you can pass it a FileInfo object.
Most methods should now accept a stream, a string or a FileInfo. This was done so raw values could be passed in via string.
I totally get that. I was just surprised it stopped working.
It's not a big deal to wrap it in a FileStream
or FileInfo
.
Would be super nice, if the method hat some decorators.
/// <summary>
///
/// </summary>
/// <param name="publicKey">The raw string of the key-files content itself</param>
/// <returns></returns>
That way pressing F12 in VS would instantly reveal the problem.
Would be also nice to check if a FileInfo
or Stream
could be opened. If so just recursively call the method.
That way it's convenient and does not break existing applications - OR - check if it's a filepath and throw an exception accordingly
Right now this could be a bit misleading imo
Good point, additional decorations would certainly be useful.
Commented these specific methods in v5.3.2
I am using version
5.3.1
.To my understanding ReadPublicKey(string file) should just be a wrapper and open a stream itself.