Click here to Skip to main content
15,890,506 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDialog Communication Pin
fjlv200529-Sep-05 22:30
fjlv200529-Sep-05 22:30 
AnswerRe: Dialog Communication Pin
Cedric Moonen29-Sep-05 22:36
Cedric Moonen29-Sep-05 22:36 
GeneralRe: Dialog Communication Pin
fjlv200529-Sep-05 22:56
fjlv200529-Sep-05 22:56 
QuestionMFC reporting tools? Pin
bryan52329-Sep-05 22:02
bryan52329-Sep-05 22:02 
QuestionLogFile Pin
SachinSingla29-Sep-05 22:00
SachinSingla29-Sep-05 22:00 
AnswerRe: LogFile Pin
ThatsAlok29-Sep-05 22:27
ThatsAlok29-Sep-05 22:27 
AnswerRe: LogFile Pin
ThatsAlok29-Sep-05 22:28
ThatsAlok29-Sep-05 22:28 
QuestionAcquireCredentialsHandle returns SEC_E_INTERNAL_ERROR Pin
sunit529-Sep-05 21:32
sunit529-Sep-05 21:32 
I am programming Socket with SSL on server side. The following code depicts how
I m reteriving certificate from a store and obtaining credentials for
schannel.I am getting problem in obtaning credential handle ie AcquireCredentialshandle returns SEC_E_INTERNAL_ERROR


#define ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)


TimeStamp tsExpiry;
SECURITY_STATUS Status;
CERT_RDN cert_rdn;// structure to obtain certificate using RDN
attributes
//containing structure CERT_RDN_ATTR


CERT_RDN_ATTR cert_rdn_attr;// structure for one attribute of RDN ie
//Common Name


//only one attribute of RDN is used to find certificate
cert_rdn.cRDNAttr = 1;//only one CERT_RDN_ATTR
cert_rdn.rgRDNAttr =&cert_rdn_attr;//pointer to CERT_RDN_ATTR the
//structure contains 1 attribute


const TCHAR * pszUserName=_T("SNS");//Common Name is SNS


cert_rdn_attr.pszObjId = szOID_COMMON_NAME;//go for Common Name
//attribte in RDN
cert_rdn_attr.dwValueType = CERT_RDN_ANY_TYPE;
cert_rdn_attr.Value.cbData = _tcslen(pszUserName);//length of //Common
Name


#ifdef _UNICODE
char *pszUn = new char[wcslen(pszUserName)+1];


WideCharToMultiByte(CP_ACP,0,pszUserName,-1,pszUn,wcslen(pszUserName)+1,NULL,NULL);
cert_rdn_attr.Value.pbData = (BYTE *)pszUn;
#else
cert_rdn_attr.Value.pbData = (BYTE *)pszUserName;
#endif


//search for the certificate in the certificate store


PCCERT_CONTEXT m_pCertContext;
m_pCertContext =
CertFindCertificateInStore(m_hMyCertStore,
ENCODING_TYPE,
0,//use default values
CERT_FIND_SUBJECT_ATTR,
&cert_rdn,
NULL);


#ifdef _UNICODE
delete [] pszUn;
#endif


//If the function fails and a certificate that matches the search
criteria is not //found,the return value is NULL


if(m_pCertContext == NULL &&::GetLastError()==CRYPT_E_NOT_FOUND)
{
::OutputDebugString(_T("error:"));



}


::OutputDebugString(_T("pointer to the certificate context is
available"));

SCHANNEL_CRED m_SchannelCred;


SecurityFunctionTable m_SecurityFunc;


CredHandle m_hCreds;
PCredHandle phCreds=&m_hCreds//pointer to the credential handle


ZeroMemory(&m_SchannelCred, sizeof(m_SchannelCred));


//Credentials are required by the Schannel authentication
m_SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;


m_SchannelCred.cCreds = 1;//only one certificate store


m_SchannelCred.paCred = &m_pCertContext;//pointer to the pointer of
//CERT_CONTEXT structure this how the certificate enters the credential
//which is used for security context in schannel authentication


m_SchannelCred.hRootStore = m_hMyCertStore;//handle to certificate
store
m_SchannelCred.dwMinimumCipherStrength = 80;//strength of cipher


DWORD m_dwProtocol=0;//use any protocol
m_SchannelCred.grbitEnabledProtocols = m_dwProtocol;//use any protocol


m_SchannelCred.dwFlags |= SCH_CRED_NO_SYSTEM_MAPPER ;


//function, which returns a handle to the requested credentials
Status = m_SecurityFunc.AcquireCredentialsHandle(
NULL, // Nameof principal
UNISP_NAME,//schannel package
SECPKG_CRED_INBOUND,
NULL,
&m_SchannelCred,
NULL,
NULL,
phCreds
&tsExpiry);


//here i refered MSDN for returned Status and put different values of
Status //check the exact cause for error and i found the returned value
of Status is
//SEC_E_INTERNAL_ERROR
if(Status != SEC_E_OK &&Status==SEC_E_INTERNAL_ERROR)
{
::OutputDebugString(_T("error channel credentials"));



}


::OutputDebugString(_T("handle to channel credential is available"));

//Pls help me.Thanx in advance for any suggestion.



-- modified at 3:32 Friday 30th September, 2005
QuestionGet pixel data from DirectX or OpenGL Pin
29-Sep-05 21:22
suss29-Sep-05 21:22 
AnswerRe: Get pixel data from DirectX or OpenGL Pin
Bartosz Bien30-Sep-05 1:04
Bartosz Bien30-Sep-05 1:04 
Questionwindows printer spool Pin
Marc Soleda29-Sep-05 20:55
Marc Soleda29-Sep-05 20:55 
QuestionWindows 98 DDK Pin
karmendra_js29-Sep-05 20:47
karmendra_js29-Sep-05 20:47 
AnswerRe: Windows 98 DDK Pin
tssp29-Sep-05 21:10
tssp29-Sep-05 21:10 
QuestionWindows Error Message Pin
.NetRams29-Sep-05 19:50
.NetRams29-Sep-05 19:50 
AnswerRe: Windows Error Message Pin
Mircea Puiu30-Sep-05 21:23
Mircea Puiu30-Sep-05 21:23 
QuestionCAsyncSocket vs CAsyncSocketEx Pin
Suraihan29-Sep-05 19:38
Suraihan29-Sep-05 19:38 
QuestionBitmap Dialog. Pin
rajeev8229-Sep-05 19:10
rajeev8229-Sep-05 19:10 
AnswerRe: Bitmap Dialog. Pin
ThatsAlok29-Sep-05 19:26
ThatsAlok29-Sep-05 19:26 
GeneralRe: Bitmap Dialog. Pin
vikas amin29-Sep-05 19:50
vikas amin29-Sep-05 19:50 
GeneralRe: Bitmap Dialog. Pin
ThatsAlok29-Sep-05 20:12
ThatsAlok29-Sep-05 20:12 
GeneralRe: Bitmap Dialog. Pin
vikas amin29-Sep-05 22:55
vikas amin29-Sep-05 22:55 
AnswerRe: Bitmap Dialog. Pin
vikas amin29-Sep-05 20:49
vikas amin29-Sep-05 20:49 
QuestionDisplaying Text in System Tray Pin
hairam29-Sep-05 19:01
hairam29-Sep-05 19:01 
AnswerRe: Displaying Text in System Tray Pin
douglasjordan30-Sep-05 4:47
douglasjordan30-Sep-05 4:47 
GeneralRe: Displaying Text in System Tray Pin
hairam1-Oct-05 6:32
hairam1-Oct-05 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.