diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 01:13:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 01:13:27 +0700 |
commit | a8a17fd70fc8df3ca7402323ad5c4f36b25cb806 (patch) | |
tree | 9b276b62885505abbb899d17744b65b912072140 /crypto/src/tsp/TimeStampTokenGenerator.cs | |
parent | Primes improvements (diff) | |
download | BouncyCastle.NET-ed25519-a8a17fd70fc8df3ca7402323ad5c4f36b25cb806.tar.xz |
Dispose cleanup
- IDisposable for PemReader, PemWriter, IStreamGenerator
Diffstat (limited to 'crypto/src/tsp/TimeStampTokenGenerator.cs')
-rw-r--r-- | crypto/src/tsp/TimeStampTokenGenerator.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/src/tsp/TimeStampTokenGenerator.cs b/crypto/src/tsp/TimeStampTokenGenerator.cs index 930463ca3..c2aae37e2 100644 --- a/crypto/src/tsp/TimeStampTokenGenerator.cs +++ b/crypto/src/tsp/TimeStampTokenGenerator.cs @@ -81,12 +81,14 @@ namespace Org.BouncyCastle.Tsp try { - IStreamCalculator<IBlockResult> calculator = digestCalculator.CreateCalculator(); - Stream stream = calculator.Stream; byte[] certEnc = assocCert.GetEncoded(); - stream.Write(certEnc, 0, certEnc.Length); - stream.Flush(); - Platform.Dispose(stream); + + IStreamCalculator<IBlockResult> calculator = digestCalculator.CreateCalculator(); + + using (var stream = calculator.Stream) + { + stream.Write(certEnc, 0, certEnc.Length); + } if (((AlgorithmIdentifier)digestCalculator.AlgorithmDetails).Algorithm.Equals(OiwObjectIdentifiers.IdSha1)) { |