Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2005-01-21 03:37:04 +0300
committerSebastien Pouliot <sebastien@ximian.com>2005-01-21 03:37:04 +0300
commitfce0519581b30a079544e3d145f05f6a93a8f6fb (patch)
treed258a6d58a6e74fbd795ff52816e553f68cf0dca /mcs/class/System.Security/System.Security.Cryptography
parent7d463eeaf8dc5895fa58aa88f000cb2f97006f6b (diff)
2005-01-20 Sebastien Pouliot <sebastien@ximian.com>
* AsnEncodedData.cs: Added "internal" support for SubjectAltName extension as it is required for SSL support. * Oid.cs: Added Oid / FriendlyName definitions for SubjectAltName. svn path=/trunk/mcs/; revision=39294
Diffstat (limited to 'mcs/class/System.Security/System.Security.Cryptography')
-rwxr-xr-xmcs/class/System.Security/System.Security.Cryptography/AsnEncodedData.cs49
-rwxr-xr-xmcs/class/System.Security/System.Security.Cryptography/ChangeLog6
-rwxr-xr-xmcs/class/System.Security/System.Security.Cryptography/Oid.cs6
3 files changed, 61 insertions, 0 deletions
diff --git a/mcs/class/System.Security/System.Security.Cryptography/AsnEncodedData.cs b/mcs/class/System.Security/System.Security.Cryptography/AsnEncodedData.cs
index fe4c3f43eb1..561bcd91e25 100755
--- a/mcs/class/System.Security/System.Security.Cryptography/AsnEncodedData.cs
+++ b/mcs/class/System.Security/System.Security.Cryptography/AsnEncodedData.cs
@@ -32,6 +32,9 @@
using System.Security.Cryptography.X509Certificates;
using System.Text;
+using Mono.Security;
+using Mono.Security.Cryptography;
+
namespace System.Security.Cryptography {
internal enum AsnDecodeStatus {
@@ -143,6 +146,8 @@ namespace System.Security.Cryptography {
return SubjectKeyIdentifierExtension (multiLine);
// other known objects (i.e. supported structure) -
// but without any corresponding framework class
+ case Oid.oidSubjectAltName:
+ return SubjectAltName (multiLine);
case Oid.oidNetscapeCertType:
return NetscapeCertType (multiLine);
default:
@@ -209,6 +214,50 @@ namespace System.Security.Cryptography {
// Indirectly (undocumented but) supported extensions
+ internal string SubjectAltName (bool multiLine)
+ {
+ if (_raw.Length < 5)
+ return "Information Not Available";
+
+ try {
+ ASN1 ex = new ASN1 (_raw);
+ StringBuilder sb = new StringBuilder ();
+ for (int i=0; i < ex.Count; i++) {
+ ASN1 el = ex [i];
+
+ string type = null;
+ string name = null;
+
+ switch (el.Tag) {
+ case 0x81:
+ type = "RFC822 Name=";
+ name = Encoding.ASCII.GetString (el.Value);
+ break;
+ case 0x82:
+ type = "DNS Name=";
+ name = Encoding.ASCII.GetString (el.Value);
+ break;
+ default:
+ type = String.Format ("Unknown ({0})=", el.Tag);
+ name = CryptoConvert.ToHex (el.Value);
+ break;
+ }
+
+ sb.Append (type);
+ sb.Append (name);
+ if (multiLine) {
+ sb.Append (Environment.NewLine);
+ } else if (i < ex.Count - 1) {
+ sb.Append (", ");
+ }
+ }
+ return sb.ToString ();
+ }
+ catch {
+ return String.Empty;
+ }
+ }
+
internal string NetscapeCertType (bool multiLine)
{
// 4 byte long, BITSTRING (0x03), Value length of 2
diff --git a/mcs/class/System.Security/System.Security.Cryptography/ChangeLog b/mcs/class/System.Security/System.Security.Cryptography/ChangeLog
index 6101006b6f3..72cc0858008 100755
--- a/mcs/class/System.Security/System.Security.Cryptography/ChangeLog
+++ b/mcs/class/System.Security/System.Security.Cryptography/ChangeLog
@@ -1,3 +1,9 @@
+2005-01-20 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AsnEncodedData.cs: Added "internal" support for SubjectAltName
+ extension as it is required for SSL support.
+ * Oid.cs: Added Oid / FriendlyName definitions for SubjectAltName.
+
2005-01-17 Sebastien Pouliot <sebastien@ximian.com>
* AsnEncodedData.cs: Added more decoding/formatting code as this class
diff --git a/mcs/class/System.Security/System.Security.Cryptography/Oid.cs b/mcs/class/System.Security/System.Security.Cryptography/Oid.cs
index 9db7bac1d58..f2da65231ec 100755
--- a/mcs/class/System.Security/System.Security.Cryptography/Oid.cs
+++ b/mcs/class/System.Security/System.Security.Cryptography/Oid.cs
@@ -100,6 +100,8 @@ namespace System.Security.Cryptography {
internal const string name3Des = "3des";
internal const string oidSha1 = "1.3.14.3.2.26";
internal const string nameSha1 = "sha1";
+ internal const string oidSubjectAltName = "2.5.29.17";
+ internal const string nameSubjectAltName = "Subject Alternative Name";
internal const string oidNetscapeCertType = "2.16.840.1.113730.1.1";
internal const string nameNetscapeCertType = "Netscape Cert Type";
@@ -127,6 +129,8 @@ namespace System.Security.Cryptography {
return X509EnhancedKeyUsageExtension.friendlyName;
case X509SubjectKeyIdentifierExtension.oid:
return X509SubjectKeyIdentifierExtension.friendlyName;
+ case oidSubjectAltName:
+ return nameSubjectAltName;
case oidNetscapeCertType:
return nameNetscapeCertType;
case oidMd5:
@@ -162,6 +166,8 @@ namespace System.Security.Cryptography {
return X509EnhancedKeyUsageExtension.oid;
case X509SubjectKeyIdentifierExtension.friendlyName:
return X509SubjectKeyIdentifierExtension.oid;
+ case nameSubjectAltName:
+ return oidSubjectAltName;
case nameNetscapeCertType:
return oidNetscapeCertType;
case nameMd5: