Access denied while setting CTL name
From: Subir (Subir_at_discussions.microsoft.com)
Date: 01/22/05
- Next message: Chris Rolon: "Re: User Password set"
- Previous message: Patrick Tronnier: "How to tell Certificate Server which CA cert to use to sign a CRL?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 21 Jan 2005 15:29:02 -0800
Hi,
I am trying to change the friendly name of a CTL using Crypto API. However
the call to CertSetCTLContextProperty returns 2147942405 i.e. Access is
denied..
Am I missing something simple?
Thanks,
Subir
Code:
//open the store
hCTLStore = CertOpenSystemStore(NULL, TEXT("CA"));
pCTLContext = CertEnumCTLsInStore(hCTLStore, NULL);
while(NULL != pCTLContext)
{
if(CertGetCTLContextProperty(pCTLContext,
CERT_FRIENDLY_NAME_PROP_ID, (LPVOID) pbId, &cbId))
{
//re-initialize the array each time we are working with a new ctl
szName[0] = TEXT('\0');
//read each character from the BYTE array into a string.
//TODO: find a better way to do the same.
for(DWORD i = 0; i < cbId; i++)
{
hr = StringCchPrintf(szTemp, ARRAYSIZE(szTemp), TEXT("%c"),
(unsigned char)pbId[i]);
if (SUCCEEDED(hr))
{
hr = StringCchCat(szName, ARRAYSIZE(szName), szTemp);
}
}
//if(0 == _tcscmp(szName, _T("TestCTL")))
{
TCHAR* friendlyName = new TCHAR[_tcslen(_T("NewCTLName"))+1];
_tcscpy(friendlyName, _T("NewCTLName"));
CRYPT_DATA_BLOB data;
data.cbData = (_tcslen(friendlyName)+1) * sizeof(TCHAR);
data.pbData = (BYTE*)friendlyName;
error = GetLastError();
BOOL returnValue =
CertSetCTLContextProperty(pCTLContext, CERT_FRIENDLY_NAME_PROP_ID, 0 ,
(void*)&data);
if(!returnValue)
{
error = GetLastError();
}
//break;
}
//else
{
//move to the next ctl
pCTLContext = CertEnumCTLsInStore(hCTLStore, pCTLContext);
}
}
}
- Next message: Chris Rolon: "Re: User Password set"
- Previous message: Patrick Tronnier: "How to tell Certificate Server which CA cert to use to sign a CRL?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]