X509Certificate Constructor (array<Byte>^)
Initializes a new instance of the X509Certificate class defined from a sequence of bytes representing an X.509v3 certificate.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- data
-
Type:
array<System::Byte>^
A byte array containing data from an X.509 certificate.
| Exception | Condition |
|---|---|
| CryptographicException | An error with the certificate occurs. For example:
|
| ArgumentException | The rawData parameter is null. -or- The length of the rawData parameter is 0. |
ASN.1 DER is the only certificate format supported by this class.
If you create an X509Certificate certificate by specifying a PKCS7 signed file store for data, the X509Certificate is created for the certificate that signed the store rather than for any of the certificates within the store.
The following example loads an X.509 certificate file into an X509Certificate object, exports the certificate as a byte array, and then imports the byte array into another X509Certificate object.
using namespace System; using namespace System::Security::Cryptography::X509Certificates; int main() { // The path to the certificate. String^ Certificate = L"test.pfx"; // Load the certificate into an X509Certificate object. X509Certificate^ cert = gcnew X509Certificate( Certificate ); array<Byte>^certData = cert->Export( X509ContentType::Cert ); X509Certificate^ newCert = gcnew X509Certificate( certData ); // Get the value. String^ resultsTrue = newCert->ToString( true ); // Display the value to the console. Console::WriteLine( resultsTrue ); // Get the value. String^ resultsFalse = newCert->ToString( false ); // Display the value to the console. Console::WriteLine( resultsFalse ); }
for permission to create a key container. Security action: Demand. Associated enumeration: KeyContainerPermissionFlags::Create
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0