Пример #1
0
STDMETHODIMP CComCertificate::get_szPropIssuerName(BSTR *pVal)
{
  DigiDocMemBuf mbuf1, mbuf2;

  mbuf1.pMem = 0;
  mbuf1.nLen = 0;
  mbuf2.pMem = 0;
  mbuf2.nLen = 0;
  USES_CONVERSION;
  if (::ddocCertGetIssuerDN((X509*)m_pX509, &mbuf1) != 0) {
     SetBSTR(pVal,""); //*pVal = SysAllocString(A2OLE(""));
  } else {
	 ddocMemSetLength(&mbuf2, mbuf1.nLen + 10);
     utf82oem((const char*)mbuf1.pMem, (char*)mbuf2.pMem, mbuf2.nLen);
     SetBSTR(pVal, (char*)mbuf2.pMem); //*pVal = SysAllocStringLen(A2OLE(buf), bLen);
  }
  ddocMemBuf_free(&mbuf1);
  ddocMemBuf_free(&mbuf2);
  return S_OK;
}
Пример #2
0
//--------------------------------------------------
// Helper function to write OCSP_RESPONSE to binary output data
// pResp - address of OCSP_RESPONSE object
// pMBufOutData - output data
// returns error code or ERR_OK
//--------------------------------------------------
int ddocOcspWriteOcspResp(OCSP_RESPONSE* pResp, DigiDocMemBuf* pMBufOutData)
{
  int err = ERR_OK, l1;
  unsigned char* p1;

  RETURN_IF_NULL_PARAM(pResp);
  RETURN_IF_NULL_PARAM(pMBufOutData);
  pMBufOutData->pMem = NULL;
  pMBufOutData->nLen = 0;
  // find out how big a buffer we need
  l1 = i2d_OCSP_RESPONSE(pResp, NULL);
  ddocDebug(4, "ddocOcspReadOcspResp", "converting: %d bytes from OCSP_RESPONSE", l1);
  // alloc mem
  err = ddocMemSetLength(pMBufOutData, l1 + 50);  
  p1 = (unsigned char*)pMBufOutData->pMem;
  l1 = i2d_OCSP_RESPONSE(pResp, &p1);
  pMBufOutData->nLen = l1;
  ddocDebug(4, "ddocOcspReadOcspResp", "Converted data: %d", l1);
  return err;
}
Пример #3
0
STDMETHODIMP CComDigiDocLib::getCertIssuerName(long hCert, BSTR *pszStoreTo, long *nRetResult)
{
  DigiDocMemBuf mbuf1, mbuf2;

  mbuf1.pMem = 0;
  mbuf1.nLen = 0;
  mbuf2.pMem = 0;
  mbuf2.nLen = 0;
  *nRetResult = ::ddocCertGetIssuerDN((X509*)hCert, &mbuf1);
  if (*nRetResult == 0) {
    // allocate as much mem in mbuf2 plus some extra. 
    // Converting to 8 bit makes string shorter so this will be enought
    ddocMemSetLength(&mbuf2, mbuf1.nLen + 10);
    utf82oem((const char*)mbuf1.pMem, (char*)mbuf2.pMem, mbuf2.nLen);
    USES_CONVERSION;
    SetBSTR(pszStoreTo, (char*)mbuf2.pMem); //*pszStoreTo = SysAllocString(A2OLE(buf));
  }
  ddocMemBuf_free(&mbuf1);
  ddocMemBuf_free(&mbuf2);
  return S_OK;
}