Author: spouliot
Date: 2006-11-17 15:30:21 -0500 (Fri, 17 Nov 2006)
New Revision: 68091
Modified:
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate20.cs
Log:
2006-11-17 Sebastien Pouliot <[EMAIL PROTECTED]>
* X509Certificate.cs: Fix Equals to throw a CryptographicException, in
2.0 profile, if the certificate instance is empty.
* X509Certificate20.cs: Fix Reset method to reset every fields (as the
instance can be reused in 2.0). Updated MonoTODO attributes.
Modified:
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
===================================================================
---
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
2006-11-17 19:42:25 UTC (rev 68090)
+++
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
2006-11-17 20:30:21 UTC (rev 68091)
@@ -1,3 +1,10 @@
+2006-11-17 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * X509Certificate.cs: Fix Equals to throw a CryptographicException, in
+ 2.0 profile, if the certificate instance is empty.
+ * X509Certificate20.cs: Fix Reset method to reset every fields (as the
+ instance can be reused in 2.0). Updated MonoTODO attributes.
+
2006-11-08 Sebastien Pouliot <[EMAIL PROTECTED]>
* X509Certificate.cs: Refactored 2.0 support (partial class) and added
Modified:
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
===================================================================
---
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
2006-11-17 19:42:25 UTC (rev 68090)
+++
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
2006-11-17 20:30:21 UTC (rev 68091)
@@ -200,8 +200,15 @@
if (cert == null) {
return false;
} else {
- if (cert.x509 == null)
+ if (cert.x509 == null) {
+#if NET_2_0
+ if (x509 == null)
+ return true;
+ throw new CryptographicException
(Locale.GetText ("Certificate instance is empty."));
+#else
return (x509 == null);
+#endif
+ }
byte[] raw = cert.x509.RawData;
if (raw != null) {
Modified:
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate20.cs
===================================================================
---
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate20.cs
2006-11-17 19:42:25 UTC (rev 68090)
+++
trunk/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate20.cs
2006-11-17 20:30:21 UTC (rev 68091)
@@ -41,7 +41,7 @@
namespace System.Security.Cryptography.X509Certificates {
[ComVisible (true)]
- [MonoTODO ("only support DER encoded certficates and PKCS#12 formats")]
+ [MonoTODO ("X509ContentType.SerializedCert isn't supported (anywhere in
the class)")]
public partial class X509Certificate : IDeserializationCallback,
ISerializable {
private string issuer_name;
@@ -132,7 +132,6 @@
}
[ComVisible (false)]
- [MonoTODO ("Always returns 0 as X509Certificate is completely
managed with Mono.")]
public IntPtr Handle {
get { return IntPtr.Zero; }
}
@@ -147,24 +146,26 @@
return false;
}
- [MonoTODO ("only export for X509ContentType.Cert")]
+ [MonoTODO ("X509ContentType.Pfx/Pkcs12 and SerializedCert are
not supported")]
[ComVisible (false)]
public virtual byte[] Export (X509ContentType contentType)
{
return Export (contentType, (byte[])null);
}
- [MonoTODO ("only export for X509ContentType.Cert")]
+ [MonoTODO ("X509ContentType.Pfx/Pkcs12 and SerializedCert are
not supported")]
[ComVisible (false)]
public virtual byte[] Export (X509ContentType contentType,
string password)
{
- return Export (contentType, Encoding.UTF8.GetBytes
(password));
+ byte[] pwd = (password == null) ? null :
Encoding.UTF8.GetBytes (password);
+ return Export (contentType, pwd);
}
- [MonoTODO ("SecureString support is incomplete, only export for
X509ContentType.Cert")]
+ [MonoTODO ("X509ContentType.Pfx/Pkcs12 and SerializedCert are
not supported. SecureString support is incomplete.")]
public virtual byte[] Export (X509ContentType contentType,
SecureString password)
{
- return Export (contentType, password.GetBuffer ());
+ byte[] pwd = (password == null) ? null :
password.GetBuffer ();
+ return Export (contentType, pwd);
}
internal byte[] Export (X509ContentType contentType, byte[]
password)
@@ -176,8 +177,15 @@
switch (contentType) {
case X509ContentType.Cert:
return x509.RawData;
+ case X509ContentType.Pfx: // this includes
Pkcs12
+ // TODO
+ throw new NotSupportedException ();
+ case X509ContentType.SerializedCert:
+ // TODO
+ throw new NotSupportedException ();
default:
- throw new NotSupportedException ();
+ string msg = Locale.GetText ("This
certificate format '{0}' cannot be exported.", contentType);
+ throw new CryptographicException (msg);
}
}
finally {
@@ -201,6 +209,7 @@
[ComVisible (false)]
public virtual void Import (byte[] rawData, string password,
X509KeyStorageFlags keyStorageFlags)
{
+ Reset ();
if (password == null) {
try {
x509 = new
Mono.Security.X509.X509Certificate (rawData);
@@ -275,6 +284,10 @@
public virtual void Reset ()
{
x509 = null;
+ issuer_name = null;
+ subject_name = null;
+ hideDates = false;
+ cachedCertificateHash = null;
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches