Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Created April 28, 2016 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Polaringu/a9c801e67b3fc1c9665a2f7e07cbdc12 to your computer and use it in GitHub Desktop.
Save Polaringu/a9c801e67b3fc1c9665a2f7e07cbdc12 to your computer and use it in GitHub Desktop.
PCCERT_CONTEXT hCertCntxt = CertFindCertificateInStore(hStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, CERT_FIND_ANY, CERT_FIND_SUBJECT_STR, L"AlexII", NULL);
//Now two pieces of code:
//This one will work fine:
DWORD MyFlags = PXC::Sign_GR_Name | PXC::Sign_TX_Name | PXC::Sign_TX_Date | PXC::Sign_TX_Location | PXC::Sign_TX_Reason | PXC::Sign_TX_DName;
hr = pDoc->DeferedDigitalSign((PXC::_CERT_CONTEXT*)hCertCntxt, MyFlags, 0, &rc, L"Signed by", L"", L"Support@...", L"");
//And this one will give the error:
PXC::_CERT_CONTEXT st = *(PXC::_CERT_CONTEXT*)hCertCntxt;
DWORD MyFlags = PXC::Sign_GR_Name | PXC::Sign_TX_Name | PXC::Sign_TX_Date | PXC::Sign_TX_Location | PXC::Sign_TX_Reason | PXC::Sign_TX_DName;
hr = pDoc->DeferedDigitalSign(&st, MyFlags, 0, &rc, L"Signed by", L"", L"Support@...", L"");
//The problem is that the _CERT_CONTEXT structure copy is made
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment