summary refs log tree commit diff
path: root/crypto/src/asn1/cms/Time.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-08 13:18:17 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-08 13:18:17 +0700
commit879bb29bb0058a0723326de6edebb201e4cbc0b8 (patch)
tree089e7769c2342a99dfa7549c57290522f72c451b /crypto/src/asn1/cms/Time.cs
parentremoved unused SecureRandom (diff)
downloadBouncyCastle.NET-ed25519-879bb29bb0058a0723326de6edebb201e4cbc0b8.tar.xz
Overhaul GeneralizedTime classes
Diffstat (limited to 'crypto/src/asn1/cms/Time.cs')
-rw-r--r--crypto/src/asn1/cms/Time.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/src/asn1/cms/Time.cs b/crypto/src/asn1/cms/Time.cs
index f054e3809..7b6b49c30 100644
--- a/crypto/src/asn1/cms/Time.cs
+++ b/crypto/src/asn1/cms/Time.cs
@@ -101,7 +101,10 @@ namespace Org.BouncyCastle.Asn1.Cms
             if (m_timeObject is Asn1UtcTime utcTime)
                 return utcTime.ToDateTime(2049).ToString(@"yyyyMMddHHmmssK", DateTimeFormatInfo.InvariantInfo);
 
-            return ((Asn1GeneralizedTime)m_timeObject).GetTime();
+            if (m_timeObject is Asn1GeneralizedTime generalizedTime)
+                return generalizedTime.ToDateTime().ToString(@"yyyyMMddHHmmss.FFFFFFFK", DateTimeFormatInfo.InvariantInfo);
+
+            throw new InvalidOperationException();
         }
     }
 }