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

◆ GetSignerInPKCS7Store()

static unsafe SafeCertContextHandle Internal.Cryptography.Pal.CertificatePal.GetSignerInPKCS7Store ( SafeCertStoreHandle hCertStore,
SafeCryptMsgHandle hCryptMsg )
inlinestaticprivate

Definition at line 509 of file CertificatePal.cs.

510 {
511 int pcbData = 4;
512 if (!global::Interop.crypt32.CryptMsgGetParam(hCryptMsg, CryptMessageParameterType.CMSG_SIGNER_COUNT_PARAM, 0, out var pvData, ref pcbData))
513 {
514 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
515 }
516 if (pvData == 0)
517 {
518 throw (-2146889714).ToCryptographicException();
519 }
520 int pcbData2 = 0;
521 if (!global::Interop.crypt32.CryptMsgGetParam(hCryptMsg, CryptMessageParameterType.CMSG_SIGNER_INFO_PARAM, 0, null, ref pcbData2))
522 {
523 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
524 }
525 fixed (byte* ptr = new byte[pcbData2])
526 {
527 if (!global::Interop.crypt32.CryptMsgGetParam(hCryptMsg, CryptMessageParameterType.CMSG_SIGNER_INFO_PARAM, 0, ptr, ref pcbData2))
528 {
529 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
530 }
532 CERT_INFO cERT_INFO = default(CERT_INFO);
533 cERT_INFO.Issuer.cbData = ptr2->Issuer.cbData;
534 cERT_INFO.Issuer.pbData = ptr2->Issuer.pbData;
535 cERT_INFO.SerialNumber.cbData = ptr2->SerialNumber.cbData;
536 cERT_INFO.SerialNumber.pbData = ptr2->SerialNumber.pbData;
537 SafeCertContextHandle pCertContext = null;
538 if (!global::Interop.crypt32.CertFindCertificateInStore(hCertStore, CertFindType.CERT_FIND_SUBJECT_CERT, &cERT_INFO, ref pCertContext))
539 {
540 throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
541 }
542 return pCertContext;
543 }
544 }

References System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error().

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