私たちのアプリケーションは、これに似た KeyBasedFileProcessor.cs を改変したものを使用して、pgp で暗号化されたファイルを復号化します。通常、これは問題なく動作しますが、特定のファイルで問題が発生しました。問題のあるコードは次のとおりです。
if (message is PgpLiteralData)
{
PgpLiteralData ld = (PgpLiteralData)message;
Stream fOut = File.Create(ld.FileName);
Stream unc = ld.GetInputStream();
Streams.PipeAll(unc, fOut);
fOut.Close();
}
else if (message is PgpOnePassSignatureList)
{
throw new PgpException("encrypted message contains a signed message - not literal data.");
}
else
{
// the code goes here and throw this exception, when I debug, message is of type PgpMarker
throw new PgpException("message is not a simple encrypted file - type unknown.");
}
この部分で、コードは PgpLiteralData を想定していると思います。しかし、代わりに PgpMarker を取得したため、例外がスローされました。PgpMarker があるのはなぜですか? 代わりに PgpLiteralData を見つける方法は?