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

◆ FindByCertificatePolicy()

unsafe void Internal.Cryptography.Pal.FindPal.FindByCertificatePolicy ( string oidValue)
inline

Implements Internal.Cryptography.Pal.IFindPal.

Definition at line 449 of file FindPal.cs.

450 {
451 FindCore(oidValue, delegate(string oidValue, SafeCertContextHandle pCertContext)
452 {
453 CERT_INFO* pCertInfo = pCertContext.CertContext->pCertInfo;
454 CERT_EXTENSION* ptr = global::Interop.crypt32.CertFindExtension("2.5.29.32", pCertInfo->cExtension, pCertInfo->rgExtension);
455 if (ptr == null)
456 {
457 return false;
458 }
459 bool foundMatch = false;
460 byte[] encoded = ptr->Value.ToByteArray();
461 if (!encoded.DecodeObjectNoThrow(CryptDecodeObjectStructType.X509_CERT_POLICIES, delegate(void* pvDecoded, int cbDecoded)
462 {
463 for (int i = 0; i < ((CERT_POLICIES_INFO*)pvDecoded)->cPolicyInfo; i++)
464 {
465 CERT_POLICY_INFO* ptr2 = ((CERT_POLICIES_INFO*)pvDecoded)->rgPolicyInfo + i;
466 string value = Marshal.PtrToStringAnsi(ptr2->pszPolicyIdentifier);
467 if (oidValue.Equals(value, StringComparison.OrdinalIgnoreCase))
468 {
469 foundMatch = true;
470 break;
471 }
472 }
473 }))
474 {
475 return false;
476 }
477 GC.KeepAlive(pCertContext);
478 return foundMatch;
479 });
480 }
static void KeepAlive(object? obj)
Definition GC.cs:180
Definition GC.cs:8
static unsafe? string PtrToStringAnsi(IntPtr ptr)
Definition Marshal.cs:630
unsafe CERT_EXTENSION * rgExtension
Definition CERT_INFO.cs:27

References Internal.Cryptography.Pal.Native.SafeCertContextHandle.CertContext, Internal.Cryptography.Pal.Native.CERT_INFO.cExtension, System.GC.KeepAlive(), Internal.Cryptography.Pal.Native.CERT_CONTEXT.pCertInfo, System.Runtime.InteropServices.Marshal.PtrToStringAnsi(), Internal.Cryptography.Pal.Native.CERT_INFO.rgExtension, and System.value.