Новожилова Елена написал:Это значит, что полученный штамп проверить не удалось.
Может подскажите, почему через cades.dll работаетCRYPT_SIGN_MESSAGE_PARA signPara;
signPara.cbSize = sizeof(CRYPT_SIGN_MESSAGE_PARA);
signPara.dwMsgEncodingType = X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
signPara.pSigningCert = 0;
signPara.HashAlgorithm.pszObjId = szOID_CP_GOST_R3411;
signPara.HashAlgorithm.Parameters.cbData = NULL;
signPara.cMsgCert = 0;
signPara.rgpMsgCert = NULL;
signPara.cAuthAttr = 0;
signPara.dwInnerContentType = 0;
signPara.cMsgCrl = 0;
signPara.cUnauthAttr = 0;
signPara.dwFlags = 0;
signPara.pvHashAuxInfo = NULL;
signPara.rgAuthAttr = NULL;
CADES_SIGN_PARA csp;
csp.dwSize = sizeof(CADES_SIGN_PARA);
csp.szHashAlgorithm = szOID_CP_GOST_R3411;
csp.hAdditionalStore = NULL;
csp.dwCadesType = CADES_X_LONG_TYPE_1;
CADES_SERVICE_CONNECTION_PARA servi;
servi.dwSize = sizeof(CADES_SERVICE_CONNECTION_PARA);
servi.wszUri = L"http://www.cryptopro.ru/tsp/tsp.srf";
servi.pAuthPara = NULL;
csp.pTspConnectionPara = &servi;
CADES_AUTH_PARA au;
au.dwSize = sizeof(CADES_AUTH_PARA);
au.dwAuthType = CADES_AUTH_NTLM;
au.pClientCertificate = NULL;
CADES_PROXY_PARA proxy;
proxy.dwSize = sizeof(CADES_PROXY_PARA);
proxy.pProxyAuthPara = &au;
proxy.wszProxyUri = L"http://webproxy.dy.droot.org:8080";
csp.pProxyPara = &proxy;
CADES_SIGN_MESSAGE_PARA para = { sizeof(para) };
para.pSignMessagePara = &signPara;
para.pCadesSignPara = &csp;
BYTE* pbMessage;
DWORD cbMessage;
pbMessage =
(BYTE*)TEXT("Why can't I have only timestamp?");
cbMessage = (lstrlen((TCHAR*) pbMessage) + 1) * sizeof(TCHAR);
const BYTE* MessageArray[] = {pbMessage};
DWORD_PTR MessageSizeArray[1];
MessageSizeArray[0] = cbMessage;
PCRYPT_DATA_BLOB pSignedMessage = NULL;
HCERTSTORE hst = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL,CERT_SYSTEM_STORE_CURRENT_USER, L"MY");
PCCERT_CONTEXT pSignerCert = CryptUIDlgSelectCertificateFromStore(hst, NULL, L"SELECT A CERTIFICATE", L"WHERE TO DO",0, 0, NULL);
para.pSignMessagePara->pSigningCert = pSignerCert;
try
{
if(!CadesSignMessage(¶,FALSE,1,MessageArray,MessageSizeArray,
&pSignedMessage))
{
DWORD d = GetLastError();
int r = 0;
}
}
catch(ATL::CAtlException &ex)
{
int a = 0;
}
CRYPT_VERIFY_MESSAGE_PARA cryptVerifyPara = { sizeof(cryptVerifyPara) };
cryptVerifyPara.dwMsgAndCertEncodingType =
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING;
CADES_VERIFY_MESSAGE_PARA verifyPara = { sizeof(verifyPara) };
verifyPara.pVerifyMessagePara = &cryptVerifyPara;
PCADES_VERIFICATION_INFO pVerifyInfo = 0;
PCRYPT_DATA_BLOB pContent = 0;
if(!CadesVerifyMessage(&verifyPara,0,
pSignedMessage->pbData,pSignedMessage->cbData,&pSignedMessage,&pVerifyInfo))
{
CadesFreeVerificationInfo(pVerifyInfo);
return false;
}
if(pVerifyInfo->dwStatus != CADES_VERIFY_SUCCESS )
return false;
а через tspcli.dll получаю ошибку WinHttpSetOption: error 12019 [ERROR_WINHTTP_INCORRECT_HANDLE_STATE] ?CryptoPro::PKI::TSP::Client::CRequest *req = new CryptoPro::PKI::TSP::Client::CRequest();
CryptoPro::PKI::TSP::Client::CStamp* stamp = new CryptoPro::PKI::TSP::Client::CStamp();
req->ResetData();
req->put_TSAAddress(L"http://www.cryptopro.ru/tsp/tsp.srf");
req->put_DataHashAlg(CALG_GR3411);
req->put_ProxyAuthType(CryptoPro::PKI::TSP::Client::CRequest::atNTLM);
req->put_ProxyAddress(L"http://webproxy.dy.droot.org:8080");
req->put_CertReq(true);
req->put_ClientCertificate(pSignerCert);
req->AddData(pbMessage, cbMessage);
req->Display(NULL, L"");
byte* d;
ULONG ds;
try
{
*stamp = req->Send(false);
stamp->Display(NULL, L"");
}
catch(ATL::CAtlException &ex)
{
int a = 0;
}
CertCloseStore(hst, CERT_CLOSE_STORE_FORCE_FLAG);
unsigned long httst = req->get_HTTPStatus();
Отредактировано пользователем 26 ноября 2012 г. 15:31:53(UTC)
| Причина: Не указана