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

◆ FilterPFXStore()

static unsafe SafeCertContextHandle Internal.Cryptography.Pal.CertificatePal.FilterPFXStore ( ReadOnlySpan< byte > rawData,
SafePasswordHandle password,
PfxCertStoreFlags pfxCertStoreFlags )
inlinestaticprivate

Definition at line 546 of file CertificatePal.cs.

547 {
549 fixed (byte* pbData = rawData)
550 {
551 CRYPTOAPI_BLOB pPFX = new CRYPTOAPI_BLOB(rawData.Length, pbData);
552 safeCertStoreHandle = global::Interop.crypt32.PFXImportCertStore(ref pPFX, password, pfxCertStoreFlags);
553 if (safeCertStoreHandle.IsInvalid)
554 {
555 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
556 }
557 }
558 try
559 {
561 SafeCertContextHandle pCertContext = null;
562 while (global::Interop.crypt32.CertEnumCertificatesInStore(safeCertStoreHandle, ref pCertContext))
563 {
564 if (pCertContext.ContainsPrivateKey)
565 {
566 if (!safeCertContextHandle.IsInvalid && safeCertContextHandle.ContainsPrivateKey)
567 {
568 if (pCertContext.HasPersistedPrivateKey)
569 {
571 }
572 }
573 else
574 {
575 safeCertContextHandle.Dispose();
576 safeCertContextHandle = pCertContext.Duplicate();
577 }
578 }
579 else if (safeCertContextHandle.IsInvalid)
580 {
581 safeCertContextHandle = pCertContext.Duplicate();
582 }
583 }
584 if (safeCertContextHandle.IsInvalid)
585 {
587 }
589 }
590 finally
591 {
592 safeCertStoreHandle.Dispose();
593 }
594 }
static string Cryptography_Pfx_NoCertificates
Definition SR.cs:82
Definition SR.cs:7

References Internal.Cryptography.Pal.Native.SafeCertContextHandle.ContainsPrivateKey, System.SR.Cryptography_Pfx_NoCertificates, Internal.Cryptography.Pal.Native.SafeCertContextHandleWithKeyContainerDeletion.DeleteKeyContainer(), Internal.Cryptography.Pal.Native.SafeCertContextHandle.Duplicate(), System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error(), and Internal.Cryptography.Pal.Native.SafeCertContextHandle.HasPersistedPrivateKey.

Referenced by Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile().