Share via


X509Certificate2 Constructor (Session, Byte[], String)

Initializes a new instance of the X509Certificate2 class using a byte array and a password.

Namespace: System.Security.Cryptography.X509Certificates
Assembly: System.Security (in system.security.dll)

Syntax

public X509Certificate2 (
         Session session,
         byte[] data,
         string password
)

Parameters

  • session
    Cryptoki session for which this certificate will be be created.
  • data
    A byte array containing data from an X.509 certificate.
  • password
    The password required to access the X.509 certificate data. The name of the service provider which implements the hash algorithm. This parameter is optional. If you do not provide a value, an empty string value is used.

Remarks

This constructor creates a new X509Certificate2 object using a byte array and a password that is needed to access the certificate data. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container.

Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the Ildasm.exe (MSIL Disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe.

If you create an X509Certificate2 certificate by specifying a PKCS7 signed file store for rawData, the X509Certificate2 is created for the certificate that signed the store rather than for any of the certificates within the store.

See Also

Reference

X509Certificate2 Class
X509Certificate2 Members
System.Security.Cryptography.X509Certificates Namespace