MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / GetCertificateInfo

Function GetCertificateInfo

libipc/common_name.cpp:241–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241BOOL GetCertificateInfo(PCCERT_CONTEXT pCertContext, wstring& common_name)
242{
243 BOOL fReturn = FALSE;
244 LPTSTR szName = NULL;
245 DWORD dwData;
246
247 __try
248 {
249 // Print Serial Number.
250 //_tprintf(_T("Serial Number: "));
251 dwData = pCertContext->pCertInfo->SerialNumber.cbData;
252 for (DWORD n = 0; n < dwData; n++)
253 {
254 //_tprintf(_T("%02x "),
255 // pCertContext->pCertInfo->SerialNumber.pbData[dwData - (n + 1)]);
256 }
257 //_tprintf(_T("\n"));
258
259 // Get Issuer name size.
260 if (!(dwData = CertGetNameString(pCertContext,
261 CERT_NAME_SIMPLE_DISPLAY_TYPE,
262 CERT_NAME_ISSUER_FLAG,
263 NULL,
264 NULL,
265 0)))
266 {
267 //_tprintf(_T("CertGetNameString failed.\n"));
268 __leave;
269 }
270
271 // Allocate memory for Issuer name.
272 szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR));
273 if (!szName)
274 {
275 //_tprintf(_T("Unable to allocate memory for issuer name.\n"));
276 __leave;
277 }
278
279 // Get Issuer name.
280 if (!(CertGetNameString(pCertContext,
281 CERT_NAME_SIMPLE_DISPLAY_TYPE,
282 CERT_NAME_ISSUER_FLAG,
283 NULL,
284 szName,
285 dwData)))
286 {
287 //_tprintf(_T("CertGetNameString failed.\n"));
288 __leave;
289 }
290
291 // print Issuer name.
292 //_tprintf(_T("Issuer Name: %s\n"), szName);
293 LocalFree(szName);
294 szName = NULL;
295
296 // Get Subject name size.
297 if (!(dwData = CertGetNameString(pCertContext,
298 CERT_NAME_SIMPLE_DISPLAY_TYPE,

Callers 1

GetCommonNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected