diff options
Diffstat (limited to 'mcs/class/Mono.Security/Mono.Security.X509')
5 files changed, 51 insertions, 14 deletions
diff --git a/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog b/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog index 14d6852db71..fc6c1b3b64b 100644 --- a/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog +++ b/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog @@ -1,3 +1,14 @@ +2004-09-07 Sebastien Pouliot <sebastien@ximian.com> + + * X509Chain.cs: Merge bug fixes from HEAD. + * X509Store.cs: Merge enhancements from HEAD. + +2004-07-15 Sebastien Pouliot <sebastien@ximian.com> + + * X501Name.cs: Support for E (email) in FromString. + * X520Attributes.cs: Added X520.EmailAddress. + Both patches fix bug #61241 and were contributed by Ianier Munoz. + 2004-05-27 Sebastien Pouliot <sebastien@ximian.com> * X509Certificate.cs: Rethrow original exception when parsing X.509 diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X501Name.cs b/mcs/class/Mono.Security/Mono.Security.X509/X501Name.cs index 515e24c0b9b..22e3ea30169 100644 --- a/mcs/class/Mono.Security/Mono.Security.X509/X501Name.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X501Name.cs @@ -162,6 +162,8 @@ namespace Mono.Security.X509 { case "S": // Microsoft case "ST": // RFC2253 return new X520.StateOrProvinceName (); + case "E": // NOTE: Not part of RFC2253 + return new X520.EmailAddress (); case "DC": // return streetAddress; case "UID": diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X509Chain.cs b/mcs/class/Mono.Security/Mono.Security.X509/X509Chain.cs index 254ff1b70fa..f8035e6c661 100755 --- a/mcs/class/Mono.Security/Mono.Security.X509/X509Chain.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X509Chain.cs @@ -9,9 +9,7 @@ // Sebastien Pouliot <sebastien@ximian.com> // // (C) 2003 Motus Technologies Inc. (http://www.motus.com) -// (C) 2004 Novell (http://www.novell.com) -// - +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -134,7 +132,7 @@ namespace Mono.Security.X509 { tmp = FindCertificateParent (x); if (x != null) { _chain.Add (x); - tmp = x; // last valid + x = tmp; // last valid } } // find a trusted root @@ -191,7 +189,8 @@ namespace Mono.Security.X509 { _status = X509ChainStatusFlags.NoError; roots = null; // this force a reload certs.Clear (); - _chain.Clear (); + if (_chain != null) + _chain.Clear (); } // private stuff diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X509Store.cs b/mcs/class/Mono.Security/Mono.Security.X509/X509Store.cs index 81db71b5c75..aa27a4a7dfd 100755 --- a/mcs/class/Mono.Security/Mono.Security.X509/X509Store.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X509Store.cs @@ -4,9 +4,7 @@ // Author: // Sebastien Pouliot <sebastien@ximian.com> // -// (C) 2004 Novell (http://www.novell.com) -// - +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -106,9 +104,7 @@ namespace Mono.Security.X509 { public void Import (X509Certificate certificate) { - if (!Directory.Exists (_storePath)) { - Directory.CreateDirectory (_storePath); - } + CheckStore (_storePath, true); string filename = Path.Combine (_storePath, GetUniqueName (certificate)); if (!File.Exists (filename)) { @@ -183,14 +179,28 @@ namespace Mono.Security.X509 { return crl; } - private X509CertificateCollection BuildCertificatesCollection (string storeName) + private bool CheckStore (string path, bool throwException) { - string path = Path.Combine (_storePath, storeName); - if (!Directory.Exists (path)) { + try { + if (Directory.Exists (path)) + return true; Directory.CreateDirectory (path); + return Directory.Exists (path); + } + catch { + if (throwException) + throw; + return false; } + } + private X509CertificateCollection BuildCertificatesCollection (string storeName) + { X509CertificateCollection coll = new X509CertificateCollection (); + string path = Path.Combine (_storePath, storeName); + if (!CheckStore (path, false)) + return coll; // empty collection + string[] files = Directory.GetFiles (path, "*.cer"); if ((files != null) && (files.Length > 0)) { foreach (string file in files) { @@ -213,6 +223,9 @@ namespace Mono.Security.X509 { { ArrayList list = new ArrayList (); string path = Path.Combine (_storePath, storeName); + if (!CheckStore (path, false)) + return list; // empty list + string[] files = Directory.GetFiles (path, "*.crl"); if ((files != null) && (files.Length > 0)) { foreach (string file in files) { diff --git a/mcs/class/Mono.Security/Mono.Security.X509/X520Attributes.cs b/mcs/class/Mono.Security/Mono.Security.X509/X520Attributes.cs index 54a8af9ba23..b8feb6a2db6 100644 --- a/mcs/class/Mono.Security/Mono.Security.X509/X520Attributes.cs +++ b/mcs/class/Mono.Security/Mono.Security.X509/X520Attributes.cs @@ -101,6 +101,10 @@ namespace Mono.Security.X509 { // PRINTABLESTRING asn1.Add (new ASN1 (0x13, Encoding.ASCII.GetBytes (attrValue))); break; + case 0x16: + // IA5STRING + asn1.Add (new ASN1 (0x16, Encoding.ASCII.GetBytes (attrValue))); + break; case 0x1E: // BMPSTRING asn1.Add (new ASN1 (0x1E, Encoding.BigEndianUnicode.GetBytes (attrValue))); @@ -176,6 +180,14 @@ namespace Mono.Security.X509 { } } + // NOTE: Not part of RFC2253 + public class EmailAddress : AttributeTypeAndValue + { + public EmailAddress () : base ("1.2.840.113549.1.9.1", 128, 0x16) + { + } + } + /* -- Naming attributes of type X520Title * id-at-title AttributeType ::= { id-at 12 } * |