summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/asn1/x509/GeneralName.cs31
1 files changed, 17 insertions, 14 deletions
diff --git a/crypto/src/asn1/x509/GeneralName.cs b/crypto/src/asn1/x509/GeneralName.cs
index b8794ea8f..fe00323ee 100644
--- a/crypto/src/asn1/x509/GeneralName.cs
+++ b/crypto/src/asn1/x509/GeneralName.cs
@@ -170,24 +170,25 @@ namespace Org.BouncyCastle.Asn1.X509
 
 				switch (tag)
 				{
-					case OtherName:
-						return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false));
-					case Rfc822Name:
-						return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false));
-					case DnsName:
-						return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false));
-					case X400Address:
-						throw new ArgumentException("unknown tag: " + tag);
+                    case EdiPartyName:
+                    case OtherName:
+                    case X400Address:
+                        return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false));
+
+                    case DnsName:
+                    case Rfc822Name:
+                    case UniformResourceIdentifier:
+                        return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false));
+
 					case DirectoryName:
 						return new GeneralName(tag, X509Name.GetInstance(tagObj, true));
-					case EdiPartyName:
-						return new GeneralName(tag, Asn1Sequence.GetInstance(tagObj, false));
-					case UniformResourceIdentifier:
-						return new GeneralName(tag, DerIA5String.GetInstance(tagObj, false));
 					case IPAddress:
 						return new GeneralName(tag, Asn1OctetString.GetInstance(tagObj, false));
 					case RegisteredID:
 						return new GeneralName(tag, DerObjectIdentifier.GetInstance(tagObj, false));
+
+                    default:
+                        throw new ArgumentException("unknown tag: " + tag);
 				}
 	        }
 
@@ -412,8 +413,10 @@ namespace Org.BouncyCastle.Asn1.X509
 
 		public override Asn1Object ToAsn1Object()
         {
-			// Explicitly tagged if DirectoryName
-			return new DerTaggedObject(tag == DirectoryName, tag, obj);
+            // directoryName is explicitly tagged as it is a CHOICE
+            bool isExplicit = (tag == DirectoryName);
+
+            return new DerTaggedObject(isExplicit, tag, obj);
         }
     }
 }