summary refs log tree commit diff
path: root/crypto/src/asn1/x509/Time.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/x509/Time.cs')
-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();
         }
     }
 }