Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
flohogun2  
#1 Posted : Friday, October 3, 2014 3:18:58 AM(UTC)
flohogun2

Rank: Member

Groups: Registered
Joined: 12/23/2010(UTC)
Posts: 24
Location: rennes

Thanks: 8 times
Hello,

With the CAPICOM SDK I m able to retrieve for a certificat Email and Serial number :

ISignedDataPtr oSignedData = NULL;
ISignerPtr oSigner = oSignedData->Signers->Item[1];
_bstr_t bstrMail=oSigner->Certificate->GetInfo(CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME);
_bstr_t bstrSerial=oSigner->Certificate->SerialNumber;


Is it possible to do the same with the EAGetMailObjLib::ICertificatePtr?

Best regards,

florent
ivan  
#2 Posted : Friday, October 3, 2014 7:13:24 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,152

Thanks: 9 times
Was thanked: 55 time(s) in 55 post(s)
I am sorry it doesn't support this feature. I will add those features at next version.

However, you can implement it like this in your code:

include the following headers:

Code:

#include <Wincrypt.h>
#pragma comment( lib, "Crypt32.lib" )



Code:

//oCert is EAGetMailObjLib::ICertitificatePtr;
	
	// get serial number
	PCERT_CONTEXT pCertContext = (PCERT_CONTEXT)oCert->Handle;
	int len = pCertContext->pCertInfo->SerialNumber.cbData;
	TCHAR* pszSerial = new TCHAR[2*len+1];
	pszSerial[2*len] = _T('\0');
	TCHAR* pszBuf = pszSerial;

	for( int i = len-1; i >= 0 ; i-- )
	{
		::_stprintf( pszBuf, _T("%02x"), pCertContext->pCertInfo->SerialNumber.pbData[i] );
		pszBuf +=2;
	}
	//pszSerial is the serial number
	// please use delete [] pszSerial to free the memory.

	delete [] pszSerial;

	// get email address;
	DWORD dwOut = 0;
	dwOut = ::CertGetNameString(
		pCertContext,
		CERT_NAME_EMAIL_TYPE, 
		0,
		0,
		NULL,
		0 );

	if( dwOut == 0 )
	{
		DWORD dwLastError = ::GetLastError();
		return;
	}

	TCHAR* pszEmail = new TCHAR[dwOut+1];
	pszEmail[dwOut] = _T('\0');

	dwOut = ::CertGetNameString(
		pCertContext,
		CERT_NAME_EMAIL_TYPE, 
		0,
		0,
		pszEmail,
		dwOut );

	if( dwOut == 0 )
	{
		DWORD dwLastError = ::GetLastError();
		delete []pszEmail;
		return;
	}

	// please use delete [] szEmail to free the memory.

	delete []pszEmail;
	

thanks 1 user thanked ivan for this useful post.
flohogun2 on 10/7/2014(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.046 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.