[Mono-bugs] [Bug 61796][Nor] Changed - exception getting x509 certificate info
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 6 Sep 2004 17:06:45 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by sebastien@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=61796
--- shadow/61796 2004-08-10 09:36:31.000000000 -0400
+++ shadow/61796.tmp.11381 2004-09-06 17:06:45.000000000 -0400
@@ -1,13 +1,13 @@
Bug#: 61796
Product: Mono: Class Libraries
Version: unspecified
OS: All
OS Details:
-Status: NEW
-Resolution:
+Status: RESOLVED
+Resolution: NOTABUG
Severity: Unknown
Priority: Normal
Component: CORLIB
AssignedTo: sebastien@ximian.com
ReportedBy: mart@karu15.ee
QAContact: mono-bugs@ximian.com
@@ -94,6 +94,32 @@
if (data != null)
x509 = new X509Certificate (data);
}
return x509;
}
+
+------- Additional Comments From sebastien@ximian.com 2004-09-06 17:06 -------
+Nothing wrong with the X509Certificate code. This throws a
+NullReferenceException because JCert is null after the catch.
+
+So the next line:
+Console.WriteLine (JCert.GetName ());
+will always throw a NullReferenceException if there is an exception.
+
+To avoid this the code should be rewritten like:
+
+ public static void Main (string[] args)
+ {
+ X509Certificate JCert = null;
+ string JCertFile = "JServ.cert";
+ try
+ {
+ JCert = X509Certificate.CreateFromSignedFile (JCertFile);
+ Console.WriteLine (JCert.GetName ());
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine ("Error: " + e.Message);
+ return;
+ }
+ }