Applying Digital Signatures through code
Applying Digital Signatures through code
I see the calls to do this in the new 2.5 Pro API, but how do I specify which digital signature I want to use?
Selecting Digital Signature
OK, thanks. What are acceptable values for this? PVK files? How do I select a digital signature from my signature store the way (I assume) the selector button on your full version does (I don't have this, so I am guessing as to its functionality based on the way Acrobat operates...)?
Displaying "Select Signature" dialog
OK, but is there an API call that will allow me to show the "Select Signature" dialog box, the way you do with your selection button on the driver?
Hello David,
The API that we use is CryptUIDlgSelectCertificateFromStore.
This API should be called dynamically because some systems might be missing the right version of CryptoAPI.
Example:
The API that we use is CryptUIDlgSelectCertificateFromStore.
This API should be called dynamically because some systems might be missing the right version of CryptoAPI.
Example:
Code: Select all
typedef PCCERT_CONTEXT WINAPI
CryptUIDlgSelectCertificateFromStore_T(
IN HCERTSTORE hCertStore,
IN OPTIONAL HWND hwnd,
IN OPTIONAL LPCWSTR pwszTitle,
IN OPTIONAL LPCWSTR pwszDisplayString,
IN DWORD dwDontUseColumn,
IN DWORD dwFlags,
IN VOID *pvReserved);
HCERTSTORE m_hCertStore = NULL;
PCCERT_CONTEXT m_pCertContext = NULL;
LPWSTR pszStoreName = L"MY";
CryptUIDlgSelectCertificateFromStore_T* CryptUIDlgSelectCertificateFromStore_Proc = NULL;
HMODULE m_shLib = ::LoadLibrary ("CryptUI.dll");
if(!m_shLib)
{
// generate an error;
}
CryptUIDlgSelectCertificateFromStore_Proc =
(CryptUIDlgSelectCertificateFromStore_T*)GetProcAddress (m_shLib , "CryptUIDlgSelectCertificateFromStore");
if(CryptUIDlgSelectCertificateFromStore_Proc == NULL)
{
// generate an error
}
if( (m_hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_CURRENT_USER,
pszStoreName)) == NULL)
{
// generate an error
}
if(!(m_pCertContext = CryptUIDlgSelectCertificateFromStore_Proc
(m_hCertStore, NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN,0, NULL)))
{
// generate an error
}
char m_signerName[MAX_NAME_LEN]; //This is the signer name that we are looking for
if((CertGetNameString(m_pCertContext, CERT_NAME_FRIENDLY_DISPLAY_TYPE,0, NULL, m_signerName, MAX_NAME_LEN) <= 1)
)
{
// generate an error
}
if (m_hCertStore)
CertCloseStore(m_hCertStore,0);
if(m_shLib) ::FreeLibrary (m_shLib );
return;