parent
6947bf3909
commit
fe45f2e9b1
@ -978,6 +978,7 @@ HWND CreateToolTip(int toolID, HWND hDlg, HINSTANCE hInst, const PTSTR pszText)
|
|||||||
|
|
||||||
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check)
|
bool isCertificateValidated(const generic_string & fullFilePath, const generic_string & subjectName2check)
|
||||||
{
|
{
|
||||||
|
bool isOK = false;
|
||||||
HCERTSTORE hStore = NULL;
|
HCERTSTORE hStore = NULL;
|
||||||
HCRYPTMSG hMsg = NULL;
|
HCRYPTMSG hMsg = NULL;
|
||||||
PCCERT_CONTEXT pCertContext = NULL;
|
PCCERT_CONTEXT pCertContext = NULL;
|
||||||
@ -1080,27 +1081,27 @@ bool isCertificateValidated(const generic_string & fullFilePath, const generic_s
|
|||||||
throw generic_string(TEXT("Certificate checking error: the certificate is not matched."));
|
throw generic_string(TEXT("Certificate checking error: the certificate is not matched."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up.
|
isOK = true;
|
||||||
if (pSignerInfo != NULL) LocalFree(pSignerInfo);
|
|
||||||
if (pCertContext != NULL) CertFreeCertificateContext(pCertContext);
|
|
||||||
if (hStore != NULL) CertCloseStore(hStore, 0);
|
|
||||||
if (hMsg != NULL) CryptMsgClose(hMsg);
|
|
||||||
if (szName != NULL) LocalFree(szName);
|
|
||||||
}
|
}
|
||||||
catch (generic_string s)
|
catch (generic_string s)
|
||||||
{
|
{
|
||||||
// display error message
|
// display error message
|
||||||
MessageBox(NULL, s.c_str(), TEXT("Certificate checking"), MB_OK);
|
MessageBox(NULL, s.c_str(), TEXT("Certificate checking"), MB_OK);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// Unknown error
|
||||||
|
generic_string errorMessage = TEXT("Unknown exception occured. ");
|
||||||
|
errorMessage += GetLastErrorAsString(GetLastError());
|
||||||
|
MessageBox(NULL, errorMessage.c_str(), TEXT("Certificate checking"), MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up.
|
// Clean up.
|
||||||
if (pSignerInfo != NULL) LocalFree(pSignerInfo);
|
if (pSignerInfo != NULL) LocalFree(pSignerInfo);
|
||||||
if (pCertContext != NULL) CertFreeCertificateContext(pCertContext);
|
if (pCertContext != NULL) CertFreeCertificateContext(pCertContext);
|
||||||
if (hStore != NULL) CertCloseStore(hStore, 0);
|
if (hStore != NULL) CertCloseStore(hStore, 0);
|
||||||
if (hMsg != NULL) CryptMsgClose(hMsg);
|
if (hMsg != NULL) CryptMsgClose(hMsg);
|
||||||
if (szName != NULL) LocalFree(szName);
|
if (szName != NULL) LocalFree(szName);
|
||||||
|
|
||||||
return false;
|
return isOK;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user