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

◆ FindByTemplateName()

unsafe void Internal.Cryptography.Pal.FindPal.FindByTemplateName ( string templateName)
inline

Implements Internal.Cryptography.Pal.IFindPal.

Definition at line 365 of file FindPal.cs.

366 {
367 FindCore(templateName, delegate(string templateName, SafeCertContextHandle pCertContext)
368 {
369 bool foundMatch = false;
370 CERT_INFO* pCertInfo = pCertContext.CertContext->pCertInfo;
371 CERT_EXTENSION* ptr = global::Interop.crypt32.CertFindExtension("1.3.6.1.4.1.311.20.2", pCertInfo->cExtension, pCertInfo->rgExtension);
372 if (ptr != null)
373 {
374 byte[] encoded = ptr->Value.ToByteArray();
375 if (!encoded.DecodeObjectNoThrow(CryptDecodeObjectStructType.X509_UNICODE_ANY_STRING, delegate(void* pvDecoded, int cbDecoded)
376 {
378 if (templateName.Equals(value2, StringComparison.OrdinalIgnoreCase))
379 {
380 foundMatch = true;
381 }
382 }))
383 {
384 return false;
385 }
386 }
387 if (!foundMatch)
388 {
389 CERT_EXTENSION* ptr2 = global::Interop.crypt32.CertFindExtension("1.3.6.1.4.1.311.21.7", pCertInfo->cExtension, pCertInfo->rgExtension);
390 if (ptr2 != null)
391 {
392 byte[] encoded2 = ptr2->Value.ToByteArray();
393 if (!encoded2.DecodeObjectNoThrow(CryptDecodeObjectStructType.X509_CERTIFICATE_TEMPLATE, delegate(void* pvDecoded, int cbDecoded)
394 {
396 string text = global::Interop.Crypt32.FindOidInfo(global::Interop.Crypt32.CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, templateName, OidGroup.Template, fallBackToAllGroups: true).OID;
397 if (text == null)
398 {
400 }
401 if (text.Equals(value, StringComparison.OrdinalIgnoreCase))
402 {
403 foundMatch = true;
404 }
405 }))
406 {
407 return false;
408 }
409 }
410 }
411 GC.KeepAlive(pCertContext);
412 return foundMatch;
413 });
414 }
static void KeepAlive(object? obj)
Definition GC.cs:180
Definition GC.cs:8
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652
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(), System.Runtime.InteropServices.Marshal.PtrToStringUni(), Internal.Cryptography.Pal.Native.CERT_INFO.rgExtension, System.text, and System.value.