|
|
|
date: Fri, 11 Jan 2008 08:47:02 -0800,
group: microsoft.public.platformsdk.mapi
back
PR_USER_X509_CERTIFICATE value and Outlook contacts certificate
Hi,
I am trying to make a code that will import certificate file for contact
using c++.
The think is i didnt found anithing on the net but with outlook spy and MFC
mapi i conclude that PR_USER_X509_CERTIFICATE is the value where the
certificate(s) should be stored. This is the part of the code i use to assign
the certificate to a contact item in outlook:
{
#define PR_USER_X509_CERTIFICATE PROP_TAG( PT_MV_BINARY, 0x3A70)
#define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
HCERTSTORE hSystemStore;
HCERTSTORE hFileStore;
PCCERT_CONTEXT pCertContext = NULL;
TCHAR pszNameString[256];
BYTE* pbElement;
DWORD cbElement;
//open certificate from file
hSystemStore = CertOpenSystemStore(0,L"CA"));
hFileStore =
CertOpenStore(CERT_STORE_PROV_FILENAME,MY_ENCODING_TYPE,NULL,0,L"c:\\irenaCert.cer" ));
pCertContext=CertEnumCertificatesInStore(hSystemStore,pCertContext));
//assign the certificate to contact
IMessage *imsg=0;
imsg=(IMessage *)(contactItem.get_MAPIOBJECT());
SPropValue propCer;
propCer.dwAlignPad=0;
propCer.ulPropTag=PR_USER_X509_CERTIFICATE;
propCer.Value.MVbin.cValues = 1;
SBinary binSig;
binSig.lpb=pCertContext->pbCertEncoded;
binSig.cb=pCertContext->cbCertEncoded;
propCer.Value.MVbin.lpbin = &binSig;
propCer.Value.MVbin.lpbin->lpb = pCertContext->pbCertEncoded; //lpbCertBlob;
propCer.Value.MVbin.lpbin->cb =pCertContext->cbCertEncoded; //cbCertBlob;
LPSPropProblemArray pProblemArray=0;
HRESULT resProp=imsg->SetProps(1,(LPSPropValue)&propCer,&pProblemArray);
resProp=imsg->SaveChanges(FORCE_SAVE);
free(pbElement);
CertCloseStore(hSystemStore,0);
}
So everything goues fine and the value is set but the outlook cannot
recognize the certificate. I found out that the problem is in binary data
format and size and here i need help . How to generate the binary data so the
outlook can reconize the certificate.
Thanks,
Stojan
date: Fri, 11 Jan 2008 08:47:02 -0800
author: Gancev
Re: PR_USER_X509_CERTIFICATE value and Outlook contacts certificate
Hi Stojan,
There is some extra data before and after the actual certificate.
Generally the actual certificate is shifted by 12 bytes (offset 12).
I can explain in BG if you e-mail me to somebody mailbox hosted inside
imibo.com server
Regards,
Ivan
"Gancev" wrote in message
news:590F19D6-9EE9-4BC5-80E6-3F5F4D5D9789@microsoft.com...
> Hi,
> I am trying to make a code that will import certificate file for contact
> using c++.
> The think is i didnt found anithing on the net but with outlook spy and
> MFC
> mapi i conclude that PR_USER_X509_CERTIFICATE is the value where the
> certificate(s) should be stored. This is the part of the code i use to
> assign
> the certificate to a contact item in outlook:
> {
> #define PR_USER_X509_CERTIFICATE PROP_TAG( PT_MV_BINARY, 0x3A70)
> #define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
> HCERTSTORE hSystemStore;
> HCERTSTORE hFileStore;
> PCCERT_CONTEXT pCertContext = NULL;
> TCHAR pszNameString[256];
> BYTE* pbElement;
> DWORD cbElement;
> //open certificate from file
>
> hSystemStore = CertOpenSystemStore(0,L"CA"));
> hFileStore =
> CertOpenStore(CERT_STORE_PROV_FILENAME,MY_ENCODING_TYPE,NULL,0,L"c:\\irenaCert.cer"
> ));
> pCertContext=CertEnumCertificatesInStore(hSystemStore,pCertContext));
>
> //assign the certificate to contact
> IMessage *imsg=0;
> imsg=(IMessage *)(contactItem.get_MAPIOBJECT());
> SPropValue propCer;
> propCer.dwAlignPad=0;
> propCer.ulPropTag=PR_USER_X509_CERTIFICATE;
> propCer.Value.MVbin.cValues = 1;
> SBinary binSig;
> binSig.lpb=pCertContext->pbCertEncoded;
> binSig.cb=pCertContext->cbCertEncoded;
> propCer.Value.MVbin.lpbin = &binSig;
> propCer.Value.MVbin.lpbin->lpb = pCertContext->pbCertEncoded;
> //lpbCertBlob;
> propCer.Value.MVbin.lpbin->cb =pCertContext->cbCertEncoded; //cbCertBlob;
> LPSPropProblemArray pProblemArray=0;
> HRESULT resProp=imsg->SetProps(1,(LPSPropValue)&propCer,&pProblemArray);
> resProp=imsg->SaveChanges(FORCE_SAVE);
> free(pbElement);
> CertCloseStore(hSystemStore,0);
> }
>
> So everything goues fine and the value is set but the outlook cannot
> recognize the certificate. I found out that the problem is in binary data
> format and size and here i need help . How to generate the binary data so
> the
> outlook can reconize the certificate.
>
> Thanks,
> Stojan
date: Sat, 12 Jan 2008 12:03:39 +0200
author: Ivan Borissov no spam
|
|