Closed gicoprasico closed 1 year ago
Oh, I found the answer within the unit tests.
public static async Task<(bool, string)> VerifyAndRemoveSignature(string signedFileName, string publicKeyFilename) {
var cleartextFile = signedFileName.Replace(".asc", "");
var inputFile = new FileInfo(signedFileName);
var publicKey = new FileInfo(publicKeyFilename);
var encryptionKeys = new EncryptionKeys(publicKey);
var pgp = new PGP(encryptionKeys);
var result = await pgp.VerifyAndReadClearFileAsync(inputFile);
File.WriteAllText(cleartextFile, result.ClearText);
return (File.Exists(cleartextFile) && result.IsVerified, cleartextFile);
}
Thank you.
This can be closed as invalid.
Hi and thanks to all developers of this great library that simplify PGP encryption. The only part that I am not able to do is to verify clearsign signature (the embedded one within the file) and I was not able to remove the signature and produce the cleartext file.
For a encrypted and signed file (with clearsign) I got an error (Org.BouncyCastle.Bcpg.OpenPgp.PgpException: 'File was not signed.') while I was trying to decrypt and verify it:
For clearsign signature removal I did not found any way to do it. At the end I used the command line, but if there is any other way I would appreciate the feedback.