summary refs log tree commit diff
path: root/crypto/src/asn1/x509
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/x509
parentremoved unused SecureRandom (diff)
downloadBouncyCastle.NET-ed25519-879bb29bb0058a0723326de6edebb201e4cbc0b8.tar.xz
Overhaul GeneralizedTime classes
Diffstat (limited to 'crypto/src/asn1/x509')
-rw-r--r--crypto/src/asn1/x509/Time.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/src/asn1/x509/Time.cs b/crypto/src/asn1/x509/Time.cs
index 7f2d43315..e03055f6d 100644
--- a/crypto/src/asn1/x509/Time.cs
+++ b/crypto/src/asn1/x509/Time.cs
@@ -102,7 +102,10 @@ namespace Org.BouncyCastle.Asn1.X509
             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();
         }
     }
 }