MSDN Library

X509Certificate2.IssuerName Property

System.Security.Cryptography.X509Certificates.X509Certificate2.IssuerName

Namespace: System.Security.Cryptography.X509Certificates

Assembly: System.Security.Cryptography.X509Certificates.dll

Inheritance: X509Certificate2

Description

Gets the issuer name of the X.509 certificate.

The issuer name is a Distinguished Name (DN) that identifies the entity that issued the certificate. This property returns an X500DistinguishedName object representing the issuer's name.

Syntax

public override string IssuerName { get; }

Property Value

An X500DistinguishedName object that contains the issuer name.

Remarks

The IssuerName property provides a convenient way to access the issuer's distinguished name from an X509Certificate2 object. The distinguished name is typically composed of a sequence of relative distinguished names (RDNs), such as Common Name (CN), Organization (O), and Country (C).

This property is inherited from the base class X509Certificate, but the X509Certificate2 class provides an overridden version that returns an X500DistinguishedName object for more structured access to name components.

Example

The following code example demonstrates how to retrieve and display the issuer name of an X.509 certificate.

using System;
using System.Security.Cryptography.X509Certificates;

public class Example
{
    public static void Main(string[] args)
    {
        try
        {
            // Load a certificate from the certificate store. Replace with your certificate selection logic.
            X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly);
            
            if (store.Certificates.Count > 0)
            {
                X509Certificate2 certificate = store.Certificates[0]; // Get the first certificate

                // Get the issuer name
                X500DistinguishedName issuerName = certificate.IssuerName;

                Console.WriteLine("Certificate Issuer Name:");
                Console.WriteLine(issuerName.Name);

                // You can also access individual components of the issuer name
                foreach (var rdn in issuerName.Name.Split(','))
                {
                    if (rdn.TrimStart().StartsWith("CN="))
                    {
                        Console.WriteLine($"  Common Name (CN): {rdn.Substring(3).Trim()}");
                    }
                    else if (rdn.TrimStart().StartsWith("O="))
                    {
                        Console.WriteLine($"  Organization (O): {rdn.Substring(2).Trim()}");
                    }
                    else if (rdn.TrimStart().StartsWith("C="))
                    {
                        Console.WriteLine($"  Country (C): {rdn.Substring(2).Trim()}");
                    }
                }
            }
            else
            {
                Console.WriteLine("No certificates found in the CurrentUser's My store.");
            }

            store.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred: {ex.Message}");
        }
    }
}

Requirements

Client
Windows 7, Windows Vista, Windows XP SP3, Windows Server 2008, Windows Server 2003 SP2
Server
Windows Server 2012, Windows Server 2008 R2, Windows Server 2008
Framework
.NET Framework 4.5, .NET Framework 4.0, .NET Framework 3.5, .NET Framework 3.0, .NET Framework 2.0

See Also