Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryAcquireCngPrivateKey()

static SafeNCryptKeyHandle Internal.Cryptography.Pal.CertificatePal.TryAcquireCngPrivateKey ( SafeCertContextHandle certificateContext,
out CngKeyHandleOpenOptions handleOptions )
inlinestaticprivate

Definition at line 788 of file CertificatePal.cs.

789 {
790 if (!certificateContext.HasPersistedPrivateKey)
791 {
792 int pcbData = IntPtr.Size;
793 if (global::Interop.crypt32.CertGetCertificateContextProperty(certificateContext, CertContextPropId.CERT_NCRYPT_KEY_HANDLE_PROP_ID, out IntPtr pvData, ref pcbData))
794 {
797 }
798 }
799 bool pfCallerFreeProvOrNCryptKey = true;
802 try
803 {
804 int pdwKeySpec = 0;
805 if (!global::Interop.crypt32.CryptAcquireCertificatePrivateKey(certificateContext, CryptAcquireFlags.CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG, IntPtr.Zero, out phCryptProvOrNCryptKey, out pdwKeySpec, out pfCallerFreeProvOrNCryptKey))
806 {
808 phCryptProvOrNCryptKey?.SetHandleAsInvalid();
809 return null;
810 }
812 {
814 phCryptProvOrNCryptKey.SetHandleAsInvalid();
817 }
819 }
820 catch
821 {
823 {
824 phCryptProvOrNCryptKey.SetHandleAsInvalid();
825 }
826 throw;
827 }
828 }
static int Size
Definition IntPtr.cs:21
static readonly IntPtr Zero
Definition IntPtr.cs:18

References System.IntPtr.Size, and System.IntPtr.Zero.

Referenced by Internal.Cryptography.Pal.CertificatePal.GetPrivateKey< T >().