13 private int m_version;
25 private Oid m_signatureAlgorithm;
33 private static int s_publicKeyOffset;
43 if (m_safeCertContext.IsInvalid)
48 return CAPISafe.CertGetCertificateContextProperty(m_safeCertContext, 19u, SafeLocalAllocHandle.InvalidHandle, ref pcbData);
52 SafeLocalAllocHandle safeLocalAllocHandle = SafeLocalAllocHandle.InvalidHandle;
55 safeLocalAllocHandle = CAPI.LocalAlloc(64u,
new IntPtr(
Marshal.
SizeOf(typeof(CAPIBase.CRYPTOAPI_BLOB))));
57 if (!CAPI.CertSetCertificateContextProperty(m_safeCertContext, 19u, 0u, safeLocalAllocHandle))
61 safeLocalAllocHandle.Dispose();
72 if (m_safeCertContext.IsInvalid)
76 if (m_extensions ==
null)
91 if (m_safeCertContext.IsInvalid)
95 SafeLocalAllocHandle invalidHandle = SafeLocalAllocHandle.InvalidHandle;
97 if (!CAPISafe.CertGetCertificateContextProperty(m_safeCertContext, 11u, invalidHandle, ref pcbData))
101 invalidHandle = CAPI.LocalAlloc(0u,
new IntPtr(pcbData));
102 if (!CAPISafe.CertGetCertificateContextProperty(m_safeCertContext, 11u, invalidHandle, ref pcbData))
107 invalidHandle.Dispose();
112 if (m_safeCertContext.IsInvalid)
118 value =
string.Empty;
120 SetFriendlyNameExtendedProperty(m_safeCertContext, value);
131 if (m_safeCertContext.IsInvalid)
135 if (m_issuerName ==
null)
137 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)m_safeCertContext.DangerousGetHandle();
138 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
152 if (m_safeCertContext.IsInvalid)
158 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)m_safeCertContext.DangerousGetHandle();
159 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
160 long fileTime = (long)(((ulong)(uint)cERT_INFO.NotAfter.dwHighDateTime << 32) | (uint)cERT_INFO.NotAfter.dwLowDateTime);
174 if (m_safeCertContext.IsInvalid)
180 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)m_safeCertContext.DangerousGetHandle();
181 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
182 long fileTime = (long)(((ulong)(uint)cERT_INFO.NotBefore.dwHighDateTime << 32) | (uint)cERT_INFO.NotBefore.dwLowDateTime);
197 if (m_safeCertContext.IsInvalid)
202 return CAPISafe.CertGetCertificateContextProperty(m_safeCertContext, 2u, SafeLocalAllocHandle.InvalidHandle, ref pcbData);
221 if (m_privateKey ==
null)
224 if (!GetPrivateKeyInfo(m_safeCertContext, ref parameters))
246 if (m_safeCertContext.IsInvalid)
251 if (value !=
null && cspAsymmetricAlgorithm ==
null)
255 if (cspAsymmetricAlgorithm !=
null)
261 if (s_publicKeyOffset == 0)
263 s_publicKeyOffset =
Marshal.
SizeOf(typeof(CAPIBase.BLOBHEADER));
266 byte[] array = cspAsymmetricAlgorithm2.
ExportCspBlob(includePrivateParameters:
false);
267 byte[] array2 = cspAsymmetricAlgorithm.
ExportCspBlob(includePrivateParameters:
false);
268 if (array ==
null || array2 ==
null || array.Length != array2.Length || array.Length <= s_publicKeyOffset)
272 for (
int i = s_publicKeyOffset; i < array.Length; i++)
274 if (array[i] != array2[i])
280 SetPrivateKeyProperty(m_safeCertContext, cspAsymmetricAlgorithm);
281 m_privateKey = value;
292 if (m_safeCertContext.IsInvalid)
296 if (m_publicKey ==
null)
323 if (m_safeCertContext.IsInvalid)
327 if (m_subjectName ==
null)
329 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)m_safeCertContext.DangerousGetHandle();
330 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
333 return m_subjectName;
344 if (m_safeCertContext.IsInvalid)
348 if (m_signatureAlgorithm ==
null)
350 m_signatureAlgorithm = GetSignatureAlgorithm(m_safeCertContext);
352 return m_signatureAlgorithm;
367 if (m_safeCertContext.IsInvalid)
373 m_version = (int)GetVersion(m_safeCertContext);
392 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
400 : base(rawData, password)
402 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
410 : base(rawData, password)
412 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
421 : base(rawData, password, keyStorageFlags)
423 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
432 : base(rawData, password, keyStorageFlags)
434 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
443 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
451 : base(fileName, password)
453 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
461 : base(fileName, password)
463 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
472 : base(fileName, password, keyStorageFlags)
474 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
483 : base(fileName, password, keyStorageFlags)
485 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
496 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
505 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
514 : base(info, context)
516 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
523 return base.ToString(fVerbose:
true);
532 if (!verbose || m_safeCertContext.IsInvalid)
538 string value = newLine + newLine;
539 string value2 = newLine +
" ";
540 stringBuilder.
Append(
"[Version]");
541 stringBuilder.
Append(value2);
543 stringBuilder.
Append(value);
544 stringBuilder.
Append(
"[Subject]");
545 stringBuilder.
Append(value2);
548 if (nameInfo.Length > 0)
550 stringBuilder.
Append(value2);
551 stringBuilder.
Append(
"Simple Name: ");
552 stringBuilder.
Append(nameInfo);
555 if (nameInfo2.Length > 0)
557 stringBuilder.
Append(value2);
558 stringBuilder.
Append(
"Email Name: ");
559 stringBuilder.
Append(nameInfo2);
562 if (nameInfo3.Length > 0)
564 stringBuilder.
Append(value2);
565 stringBuilder.
Append(
"UPN Name: ");
566 stringBuilder.
Append(nameInfo3);
569 if (nameInfo4.Length > 0)
571 stringBuilder.
Append(value2);
572 stringBuilder.
Append(
"DNS Name: ");
573 stringBuilder.
Append(nameInfo4);
575 stringBuilder.
Append(value);
576 stringBuilder.
Append(
"[Issuer]");
577 stringBuilder.
Append(value2);
580 if (nameInfo.Length > 0)
582 stringBuilder.
Append(value2);
583 stringBuilder.
Append(
"Simple Name: ");
584 stringBuilder.
Append(nameInfo);
587 if (nameInfo2.Length > 0)
589 stringBuilder.
Append(value2);
590 stringBuilder.
Append(
"Email Name: ");
591 stringBuilder.
Append(nameInfo2);
594 if (nameInfo3.Length > 0)
596 stringBuilder.
Append(value2);
597 stringBuilder.
Append(
"UPN Name: ");
598 stringBuilder.
Append(nameInfo3);
601 if (nameInfo4.Length > 0)
603 stringBuilder.
Append(value2);
604 stringBuilder.
Append(
"DNS Name: ");
605 stringBuilder.
Append(nameInfo4);
607 stringBuilder.
Append(value);
608 stringBuilder.
Append(
"[Serial Number]");
609 stringBuilder.
Append(value2);
611 stringBuilder.
Append(value);
612 stringBuilder.
Append(
"[Not Before]");
613 stringBuilder.
Append(value2);
615 stringBuilder.
Append(value);
616 stringBuilder.
Append(
"[Not After]");
617 stringBuilder.
Append(value2);
619 stringBuilder.
Append(value);
620 stringBuilder.
Append(
"[Thumbprint]");
621 stringBuilder.
Append(value2);
623 stringBuilder.
Append(value);
624 stringBuilder.
Append(
"[Signature Algorithm]");
625 stringBuilder.
Append(value2);
627 stringBuilder.
Append(value);
628 stringBuilder.
Append(
"[Public Key]");
633 stringBuilder.
Append(value2);
634 stringBuilder.
Append(
"Algorithm: ");
635 stringBuilder.
Append(friendlyName);
638 friendlyName = publicKey.
Key.
KeySize.ToString();
639 stringBuilder.
Append(value2);
640 stringBuilder.
Append(
"Length: ");
641 stringBuilder.
Append(friendlyName);
647 stringBuilder.
Append(value2);
648 stringBuilder.
Append(
"Key Blob: ");
649 stringBuilder.
Append(friendlyName);
651 stringBuilder.
Append(value2);
652 stringBuilder.
Append(
"Parameters: ");
653 stringBuilder.
Append(friendlyName);
658 AppendPrivateKeyInfo(stringBuilder);
660 if (extensions.
Count > 0)
662 stringBuilder.
Append(value);
663 stringBuilder.
Append(
"[Extensions]");
671 stringBuilder.
Append(newLine);
672 stringBuilder.
Append(
"* " + friendlyName2);
674 friendlyName2 = current.
Format(multiLine:
true);
675 stringBuilder.
Append(value2);
676 stringBuilder.
Append(friendlyName2);
683 stringBuilder.
Append(newLine);
694 uint dwFlags = forIssuer ? 1u : 0u;
699 return CAPI.GetCertNameInfo(m_safeCertContext, dwFlags, num);
701 return CAPI.GetCertNameInfo(m_safeCertContext, dwFlags, num);
704 string text =
string.Empty;
705 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)m_safeCertContext.DangerousGetHandle();
706 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
709 CAPISafe.CertFindExtension(forIssuer ?
"2.5.29.8" :
"2.5.29.7", cERT_INFO.cExtension, cERT_INFO.rgExtension),
710 CAPISafe.CertFindExtension(forIssuer ?
"2.5.29.18" :
"2.5.29.17", cERT_INFO.cExtension, cERT_INFO.rgExtension)
712 for (
int i = 0; i < array.Length; i++)
718 CAPIBase.CERT_EXTENSION cERT_EXTENSION = (CAPIBase.CERT_EXTENSION)
Marshal.
PtrToStructure(array[i], typeof(CAPIBase.CERT_EXTENSION));
719 byte[] array2 =
new byte[cERT_EXTENSION.Value.cbData];
720 Marshal.
Copy(cERT_EXTENSION.Value.pbData, array2, 0, array2.Length);
721 uint cbDecodedValue = 0u;
722 SafeLocalAllocHandle decodedValue =
null;
724 bool flag = CAPI.DecodeObject(safeLocalAllocHandle.DangerousGetHandle(), array2, out decodedValue, out cbDecodedValue);
725 safeLocalAllocHandle.Dispose();
730 CAPIBase.CERT_ALT_NAME_INFO cERT_ALT_NAME_INFO = (CAPIBase.CERT_ALT_NAME_INFO)
Marshal.
PtrToStructure(decodedValue.DangerousGetHandle(), typeof(CAPIBase.CERT_ALT_NAME_INFO));
731 for (
int j = 0; j < cERT_ALT_NAME_INFO.cAltEntry; j++)
734 CAPIBase.CERT_ALT_NAME_ENTRY cERT_ALT_NAME_ENTRY = (CAPIBase.CERT_ALT_NAME_ENTRY)
Marshal.
PtrToStructure(ptr, typeof(CAPIBase.CERT_ALT_NAME_ENTRY));
739 if (cERT_ALT_NAME_ENTRY.dwAltNameChoice != 1)
743 CAPIBase.CERT_OTHER_NAME cERT_OTHER_NAME = (CAPIBase.CERT_OTHER_NAME)
Marshal.
PtrToStructure(cERT_ALT_NAME_ENTRY.Value.pOtherName, typeof(CAPIBase.CERT_OTHER_NAME));
744 if (!(cERT_OTHER_NAME.pszObjId ==
"1.3.6.1.4.1.311.20.2.3"))
748 uint cbDecodedValue2 = 0u;
749 SafeLocalAllocHandle decodedValue2 =
null;
752 CAPIBase.CERT_NAME_VALUE cERT_NAME_VALUE = (CAPIBase.CERT_NAME_VALUE)
Marshal.
PtrToStructure(decodedValue2.DangerousGetHandle(), typeof(CAPIBase.CERT_NAME_VALUE));
757 decodedValue2.Dispose();
762 if (cERT_ALT_NAME_ENTRY.dwAltNameChoice == 3)
768 if (cERT_ALT_NAME_ENTRY.dwAltNameChoice == 7)
775 decodedValue.Dispose();
777 if (nameType ==
X509NameType.DnsName && (text ==
null || text.Length == 0))
779 text = CAPI.GetCertNameInfo(m_safeCertContext, dwFlags, 3u);
790 public override void Import(
byte[] rawData)
793 base.Import(rawData);
794 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
806 base.Import(rawData, password, keyStorageFlags);
807 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
819 base.Import(rawData, password, keyStorageFlags);
820 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
827 public override void Import(
string fileName)
830 base.Import(fileName);
831 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
843 base.Import(fileName, password, keyStorageFlags);
844 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
856 base.Import(fileName, password, keyStorageFlags);
857 m_safeCertContext = CAPI.CertDuplicateCertificateContext(base.Handle);
871 m_signatureAlgorithm =
null;
872 m_subjectName =
null;
874 if (!m_safeCertContext.IsInvalid)
876 m_safeCertContext.Dispose();
888 if (m_safeCertContext.IsInvalid)
892 int num =
System.
Security.
Cryptography.
X509Certificates.
X509Utils.VerifyCertificate(CertContext,
null,
null,
X509RevocationMode.Online,
X509RevocationFlag.ExcludeRoot,
DateTime.
Now,
new TimeSpan(0, 0, 0),
null,
new IntPtr(1
L),
IntPtr.
Zero);
903 if (rawData ==
null || rawData.Length == 0)
907 uint contentType = QueryCertBlobType(rawData);
918 if (fileName ==
null)
924 uint contentType = QueryCertFileType(fileName);
930 SafeLocalAllocHandle invalidHandle = SafeLocalAllocHandle.InvalidHandle;
932 if (!CAPISafe.CertGetCertificateContextProperty(safeCertContext, 2u, invalidHandle, ref pcbData))
935 if (lastWin32Error == -2146885628)
941 invalidHandle = CAPI.LocalAlloc(0u,
new IntPtr(pcbData));
942 if (!CAPISafe.CertGetCertificateContextProperty(safeCertContext, 2u, invalidHandle, ref pcbData))
945 if (lastWin32Error2 == -2146885628)
951 CAPIBase.CRYPT_KEY_PROV_INFO cRYPT_KEY_PROV_INFO = (CAPIBase.CRYPT_KEY_PROV_INFO)
Marshal.
PtrToStructure(invalidHandle.DangerousGetHandle(), typeof(CAPIBase.CRYPT_KEY_PROV_INFO));
952 parameters.ProviderName = cRYPT_KEY_PROV_INFO.pwszProvName;
953 parameters.KeyContainerName = cRYPT_KEY_PROV_INFO.pwszContainerName;
954 parameters.ProviderType = (int)cRYPT_KEY_PROV_INFO.dwProvType;
955 parameters.KeyNumber = (
int)cRYPT_KEY_PROV_INFO.dwKeySpec;
957 invalidHandle.Dispose();
963 CspKeyContainerInfo cspKeyContainerInfo =
null;
968 CspParameters parameters =
new CspParameters();
969 if (GetPrivateKeyInfo(m_safeCertContext, ref parameters))
971 cspKeyContainerInfo =
new CspKeyContainerInfo(parameters);
975 catch (SecurityException)
978 catch (CryptographicException)
981 if (cspKeyContainerInfo !=
null)
983 sb.
Append(Environment.NewLine + Environment.NewLine +
"[Private Key]");
984 sb.
Append(Environment.NewLine +
" Key Store: ");
985 sb.
Append(cspKeyContainerInfo.MachineKeyStore ?
"Machine" :
"User");
986 sb.
Append(Environment.NewLine +
" Provider Name: ");
987 sb.
Append(cspKeyContainerInfo.ProviderName);
988 sb.
Append(Environment.NewLine +
" Provider type: ");
989 sb.
Append(cspKeyContainerInfo.ProviderType);
990 sb.
Append(Environment.NewLine +
" Key Spec: ");
991 sb.
Append(cspKeyContainerInfo.KeyNumber);
992 sb.
Append(Environment.NewLine +
" Key Container Name: ");
993 sb.
Append(cspKeyContainerInfo.KeyContainerName);
996 string uniqueKeyContainerName = cspKeyContainerInfo.UniqueKeyContainerName;
997 sb.
Append(Environment.NewLine +
" Unique Key Container Name: ");
998 sb.
Append(uniqueKeyContainerName);
1000 catch (CryptographicException)
1003 catch (NotSupportedException)
1009 flag = cspKeyContainerInfo.HardwareDevice;
1010 sb.
Append(Environment.NewLine +
" Hardware Device: ");
1013 catch (CryptographicException)
1018 flag = cspKeyContainerInfo.Removable;
1019 sb.
Append(Environment.NewLine +
" Removable: ");
1022 catch (CryptographicException)
1027 flag = cspKeyContainerInfo.Protected;
1028 sb.
Append(Environment.NewLine +
" Protected: ");
1031 catch (CryptographicException)
1034 catch (NotSupportedException)
1042 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)safeCertContextHandle.DangerousGetHandle();
1043 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
1044 return new Oid(cERT_INFO.SignatureAlgorithm.pszObjId,
System.
Security.
Cryptography.OidGroup.SignatureAlgorithm, lookupFriendlyName:
false);
1049 CAPIBase.CERT_CONTEXT cERT_CONTEXT = *(CAPIBase.CERT_CONTEXT*)(
void*)safeCertContextHandle.DangerousGetHandle();
1050 CAPIBase.CERT_INFO cERT_INFO = (CAPIBase.CERT_INFO)
Marshal.
PtrToStructure(cERT_CONTEXT.pCertInfo, typeof(CAPIBase.CERT_INFO));
1051 return cERT_INFO.dwVersion + 1;
1054 private unsafe
static uint QueryCertBlobType(
byte[] rawData)
1057 if (!CAPI.CryptQueryObject(2u, rawData, 16382u, 14u, 0u, IntPtr.Zero,
new IntPtr(&result), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
1064 private unsafe
static uint QueryCertFileType(
string fileName)
1067 if (!CAPI.CryptQueryObject(1u, fileName, 16382u, 14u, 0u, IntPtr.Zero,
new IntPtr(&result), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
1077 using (safeLocalAllocHandle)
1079 CAPIBase.CRYPTOAPI_BLOB cRYPTOAPI_BLOB =
default(CAPIBase.CRYPTOAPI_BLOB);
1080 cRYPTOAPI_BLOB.cbData = (uint)(2 * (name.Length + 1));
1081 cRYPTOAPI_BLOB.pbData = safeLocalAllocHandle.DangerousGetHandle();
1082 if (!CAPI.CertSetCertificateContextProperty(safeCertContextHandle, 11u, 0u,
new IntPtr(&cRYPTOAPI_BLOB)))
1091 SafeLocalAllocHandle safeLocalAllocHandle = SafeLocalAllocHandle.InvalidHandle;
1092 if (asymmetricAlgorithm !=
null)
1094 CAPIBase.CRYPT_KEY_PROV_INFO cRYPT_KEY_PROV_INFO =
default(CAPIBase.CRYPT_KEY_PROV_INFO);
1095 cRYPT_KEY_PROV_INFO.pwszContainerName = asymmetricAlgorithm.CspKeyContainerInfo.KeyContainerName;
1096 cRYPT_KEY_PROV_INFO.pwszProvName = asymmetricAlgorithm.CspKeyContainerInfo.ProviderName;
1097 cRYPT_KEY_PROV_INFO.dwProvType = (uint)asymmetricAlgorithm.CspKeyContainerInfo.ProviderType;
1098 cRYPT_KEY_PROV_INFO.dwFlags = (asymmetricAlgorithm.CspKeyContainerInfo.MachineKeyStore ? 32u : 0u);
1099 cRYPT_KEY_PROV_INFO.cProvParam = 0u;
1100 cRYPT_KEY_PROV_INFO.rgProvParam = IntPtr.Zero;
1101 cRYPT_KEY_PROV_INFO.dwKeySpec = (uint)asymmetricAlgorithm.CspKeyContainerInfo.KeyNumber;
1102 safeLocalAllocHandle = CAPI.LocalAlloc(64u,
new IntPtr(
Marshal.
SizeOf(typeof(CAPIBase.CRYPT_KEY_PROV_INFO))));
1103 Marshal.
StructureToPtr((
object)cRYPT_KEY_PROV_INFO, safeLocalAllocHandle.DangerousGetHandle(), fDeleteOld:
false);
1107 if (!CAPI.CertSetCertificateContextProperty(safeCertContextHandle, 2u, 0u, safeLocalAllocHandle))
1114 if (!safeLocalAllocHandle.IsInvalid)
1117 safeLocalAllocHandle.Dispose();
The exception that is thrown when an error occurs during a cryptographic operation.
X509Certificate2(byte[] rawData, string password)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
virtual string GetSerialNumberString()
Returns the serial number of the X.509v3 certificate as a hexadecimal string.
virtual string GetKeyAlgorithm()
Returns the key algorithm information for this X.509v3 certificate as a string.
static string NewLine
Gets the newline string defined for this environment.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
FileIOPermissionAccess
Specifies the type of file access requested.
X509Certificate2(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
unsafe string GetNameInfo(X509NameType nameType, bool forIssuer)
Gets the subject and issuer names from a certificate.
Performs asymmetric encryption and decryption using the implementation of the T:System....
override void Import(string fileName, string password, X509KeyStorageFlags keyStorageFlags)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object with information...
Represents Abstract Syntax Notation One (ASN.1)-encoded data.
static DateTime FromFileTime(long fileTime)
Converts the specified Windows file time to an equivalent local time.
bool Archived
Gets or sets a value indicating that an X.509 certificate is archived.
X509Certificate2(string fileName, string password, X509KeyStorageFlags keyStorageFlags)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
X509Certificate2(string fileName, string password)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
PublicKey PublicKey
Gets a P:System.Security.Cryptography.X509Certificates.X509Certificate2.PublicKey object associated w...
string SerialNumber
Gets the serial number of a certificate.
override string ToString(bool verbose)
Displays an X.509 certificate in text format.
Oid Oid
Gets or sets the T:System.Security.Cryptography.Oid value for an T:System.Security....
Represents a cryptographic object identifier. This class cannot be inherited.
Supports a simple iteration over a T:System.Security.Cryptography.X509Certificates....
static readonly DateTime MinValue
Represents the smallest possible value of T:System.DateTime. This field is read-only.
Represents an X509 extension.
AsnEncodedData EncodedParameters
Gets the ASN.1-encoded representation of the public key parameters.
X509Certificate2(IntPtr handle)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
Represents the distinguished name of an X509 certificate. This class cannot be inherited.
static int SizeOf(object structure)
Returns the unmanaged size of an object in bytes.
string Value
Gets or sets the dotted number of the identifier.
CspProviderFlags
Specifies flags that modify the behavior of the cryptographic service providers (CSP).
override void Import(byte[] rawData)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object with data from a...
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
X509ContentType
Specifies the format of an X.509 certificate.
unsafe DateTime NotAfter
Gets the date in local time after which a certificate is no longer valid.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
Defines methods that allow an T:System.Security.Cryptography.AsymmetricAlgorithm class to enumerate k...
Represents a certificate's public key information. This class cannot be inherited.
AsymmetricAlgorithm PrivateKey
Gets or sets the T:System.Security.Cryptography.AsymmetricAlgorithm object that represents the privat...
X509RevocationMode
Specifies the mode used to check for X509 certificate revocation.
virtual byte [] GetKeyAlgorithmParameters()
Returns the key algorithm parameters for the X.509v3 certificate as an array of bytes.
static X509ContentType GetCertContentType(byte[] rawData)
Indicates the type of certificate contained in a byte array.
Oid Oid
Gets an object identifier (OID) object of the public key.
X509Certificate2(byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
unsafe DateTime NotBefore
Gets the date in local time on which a certificate becomes valid.
bool MoveNext()
Advances the enumerator to the next element in the T:System.Security.Cryptography....
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
X509Certificate2(byte[] rawData, SecureString password)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
X509ExtensionCollection Extensions
Gets a collection of T:System.Security.Cryptography.X509Certificates.X509Extension objects.
virtual string GetCertHashString()
Returns the SHA1 hash value for the X.509v3 certificate as a hexadecimal string.
X509NameType
Specifies the type of name the X509 certificate contains.
X509Certificate2(byte[] rawData)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Copies data from a one-dimensional, managed 32-bit signed integer array to an unmanaged memory pointe...
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
Represents a collection that can contain many different types of permissions.
string Name
Gets the comma-delimited distinguished name from an X500 certificate.
bool HasPrivateKey
Gets a value that indicates whether an T:System.Security.Cryptography.X509Certificates....
X509Certificate2(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
static void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld)
Marshals data from a managed object to an unmanaged block of memory.
override void Import(string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object with information...
Represents text that should be kept confidential, such as by deleting it from computer memory when no...
Represents a collection of T:System.Security.Cryptography.X509Certificates.X509Extension objects....
A platform-specific type that is used to represent a pointer or a handle.
X509Certificate2()
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
X509Extension Current
Gets the current element in the T:System.Security.Cryptography.X509Certificates.X509ExtensionCollecti...
static void DestroyStructure(IntPtr ptr, Type structuretype)
Frees all substructures that the specified unmanaged memory block points to.
Represents the abstract base class from which all implementations of asymmetric algorithms must inher...
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
override void Import(string fileName)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object with information...
Represents the version number of an assembly, operating system, or the common language runtime....
Contains parameters that are passed to the cryptographic service provider (CSP) that performs cryptog...
static string GetFullPath(string path)
Returns the absolute path for the specified path string.
virtual int KeySize
Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.
X509Certificate2(X509Certificate certificate)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
static X509ContentType GetCertContentType(string fileName)
Indicates the type of certificate contained in a file.
static string FormatDate(DateTime date)
Converts the specified date and time to a string.
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
Defines a wrapper object to access the cryptographic service provider (CSP) implementation of the T:S...
static unsafe string PtrToStringUni(IntPtr ptr, int len)
Allocates a managed T:System.String and copies a specified number of characters from an unmanaged Uni...
bool Verify()
Performs a X.509 chain validation using basic validation policy.
static void PtrToStructure(IntPtr ptr, object structure)
Marshals data from an unmanaged block of memory to a managed object.
X509ExtensionEnumerator GetEnumerator()
Returns an enumerator that can iterate through an T:System.Security.Cryptography.X509Certificates....
Oid SignatureAlgorithm
Gets the algorithm used to create the signature of a certificate.
virtual string Format(bool multiLine)
Returns a formatted version of the Abstract Syntax Notation One (ASN.1)-encoded data as a string.
override void Import(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object using data from ...
virtual byte [] GetRawCertData()
Returns the raw data for the entire X.509v3 certificate as an array of bytes.
virtual byte [] GetPublicKey()
Returns the public key for the X.509v3 certificate as an array of bytes.
unsafe X500DistinguishedName SubjectName
Gets the subject distinguished name from a certificate.
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
override void Import(byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
Populates an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object using data from ...
int Count
Gets the number of T:System.Security.Cryptography.X509Certificates.X509Extension objects in a T:Syste...
Represents a time interval.To browse the .NET Framework source code for this type,...
override string ToString()
Displays an X.509 certificate in text format.
X509KeyStorageFlags
Defines where and how to import the private key of an X.509 certificate.
string FriendlyName
Gets or sets the associated alias for a certificate.
unsafe X500DistinguishedName IssuerName
Gets the distinguished name of the certificate issuer.
Specifies that the class can be serialized.
string Thumbprint
Gets the thumbprint of a certificate.
static DateTime Now
Gets a T:System.DateTime object that is set to the current date and time on this computer,...
X509Certificate2(string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
AsymmetricAlgorithm Key
Gets an T:System.Security.Cryptography.RSACryptoServiceProvider or T:System.Security....
The exception that is thrown when an unexpected operation occurs during a cryptographic operation.
AsnEncodedData EncodedKeyValue
Gets the ASN.1-encoded representation of the public key value.
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Controls the ability to access files and folders. This class cannot be inherited.
static int GetLastWin32Error()
Returns the error code returned by the last unmanaged function that was called using platform invoke ...
SecurityPermissionFlag
Specifies access flags for the security permission object.
X509RevocationFlag
Specifies which X509 certificates in the chain should be checked for revocation.
X509Certificate2(string fileName, SecureString password)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
CspKeyContainerInfo CspKeyContainerInfo
Gets a T:System.Security.Cryptography.CspKeyContainerInfo object that describes additional informatio...
byte [] ExportCspBlob(bool includePrivateParameters)
Exports a blob that contains the key information associated with an T:System.Security....
Performs operations on T:System.String instances that contain file or directory path information....
Provides methods that help you use X.509 v.3 certificates.
byte [] RawData
Gets the raw data of a certificate.
override void Reset()
Resets the state of an T:System.Security.Cryptography.X509Certificates.X509Certificate2 object.
Represents an X.509 certificate.
X509Certificate2(string fileName)
Initializes a new instance of the T:System.Security.Cryptography.X509Certificates....
string FriendlyName
Gets or sets the friendly name of the identifier.