Closed 0xF6 closed 2 years ago
So, its fixed by output.Seek(0, SeekOrigin.Begin);
after await new PGP(keys).ClearSignStreamAsync(input, output);
.
But I still don't understand why such an uninformative error?
FWIW, I am similarly served a System.NullReferenceException when executing the following:
PGP pgp = new PGP(encryptionKeys); // no errors. encryptionKeys is valid.
bool verified = await pgp.VerifyClearFileAsync(inputFile); // exception thrown in here. inputFile is valid.
Hi @0xF6, this is because the method expects the stream to be at the start and used more like this.
// Act
using (Stream inputFileStream = testFactory.ContentStream)
using (Stream outputFileStream = File.Create(testFactory.SignedContentFilePath))
await pgpSign.ClearSignStreamAsync(inputFileStream, outputFileStream);
using (Stream inputFileStream = testFactory.SignedContentStream)
verified = await pgpVerify.VerifyClearStreamAsync(inputFileStream);
I agree the error isn't that useful though so I'll put in a specific check for this.
So, sample code:
And get exception on
await new PGP(keys).VerifyClearStreamAsync(output);
: