Click here to Skip to main content
15,909,651 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A complex c++ question. Pin
Joaquín M López Muñoz1-Dec-03 0:40
Joaquín M López Muñoz1-Dec-03 0:40 
GeneralRe: A complex c++ question. Pin
Anonymous1-Dec-03 2:53
Anonymous1-Dec-03 2:53 
GeneralRe: A complex c++ question. Pin
Antti Keskinen1-Dec-03 10:43
Antti Keskinen1-Dec-03 10:43 
GeneralRe: A complex c++ question. Pin
Monty21-Dec-03 20:05
Monty21-Dec-03 20:05 
QuestionHelp on DirectSoundFullDuplexCreate8() ?? Pin
elza30-Nov-03 21:25
elza30-Nov-03 21:25 
AnswerRe: Help on DirectSoundFullDuplexCreate8() ?? Pin
Roger Allen1-Dec-03 1:45
Roger Allen1-Dec-03 1:45 
GeneralRe: Help on DirectSoundFullDuplexCreate8() ?? Pin
elza1-Dec-03 1:56
elza1-Dec-03 1:56 
GeneralClient Certification with Wininet Pin
Anonymous30-Nov-03 21:13
Anonymous30-Nov-03 21:13 
Hi there,

I use MFC classes for doing a data transfer with Wininet. I need to authorize me on a server: apache/1.3.27 Ben-SSL/1.48 (Unix). It needs client certification and when done correct my client app. receives a session cookie to work with. Now my problem is, for the first request I can send the client ca and the authorisation works well. But when I want to do the next request, the send request from wininet throws an internet exception and askes for the client ca again. But this time there is no cookie in the response header as the first time. So I am not quiet sure if the problem is with the client ca or the cookie. In the IE6 I have all cookies enabled. I have not found yet a way to display the protocol header of my request.

Hope somebody can help me. Below I add some code sequences to make my problem clearer.

BOOL CWinInetTransfer::DoHttpRequest (...)
{
// If Internet Session is not already established try to create it.
if (!m_pISession)
{
m_pISession = new CInternetSession ("MyUserAgent", 1, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
}

csPage.Empty();
csErrMsg.Empty();

int nVerb (CHttpConnection::HTTP_VERB_GET); // default. used to specify Method.
CString csRequestUrl;
CString csServer;
CString csObject;
DWORD dwServiceType(0);
INTERNET_PORT nPort(0); // defines port: 80 for normal HTTP, 443 for HTTPS

// always get method is used: Url + ? + Data to send.
csRequestUrl += _T("?");
csRequestUrl += csPostData;

// Parsing Url to get Server, Object and Port.
BOOL bParseUrl = AfxParseURL(csRequestUrl, dwServiceType, csServer, csObject, nPort);

UINT nbrChar;
DWORD dwRes;

CHttpConnection *pServer = NULL;
CHttpFile *pHttpFile = NULL;

try
{
pServer = m_pISession->GetHttpConnection((const char*)csServer, // pstrServer.
INTERNET_SERVICE_HTTP, // dwflags
nPort, NULL, NULL);


DWORD dwFlags (INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT);

if (nPort==INTERNET_DEFAULT_HTTPS_PORT)
{
//we are talking secure https
dwFlags |= INTERNET_FLAG_SECURE |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
}

if(pServer)
{
pHttpFile = pServer->OpenRequest(nVerb, (const char*)csObject, NULL, 1, NULL, NULL, dwFlags);
}

BOOL bSendRequestOk = FALSE;
DWORD dwReqStatusCode(0);

for(int i=0; i < 10; i++) // stop after then tries.
{
csErrMsg.Empty();

try
{

// Do Send Request
if (nTxMethod == CHttpConnection::HTTP_VERB_GET)
{
// used get Method.
bSendRequestOk = m_pHttpRequest->SendRequest();
}

// Test Send Request.
if (!bSendRequestOk)
{
return FALSE;
}

m_pHttpRequest->QueryInfoStatusCode(dwReqStatus);

if(dwReqStatus < 300)
{
// Transfer was successful.
break; // end for loop.
}

} // end try: Send Request.

catch (CInternetException* e)
{
// Error during Send request: Wininet throws Exception: exp: Client CA needed.

// Get Error Code from Exception
dwReqStatus = e->m_dwError; // Error Code.
e->Delete();

// Shows Dialog specialised for error code. This Dialog gets Client CA from system store if needed.
DWORD dwAnswer = m_pHttpRequest->ErrorDlg(pParentWnd, dwReqStatus,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL);

if (dwAnswer == ERROR_CANCELLED)
{
// Abbruch durch den Benutzer.
return FALSE;
}
} // end catch: IE Exception

} // next for loop if needed.

// Send Request finished. Now verify status code. < 300 success, > 300 error.
if (dwReqStatus < 300)
{
// successful. Read is done later.
return TRUE;
}
else
{
// Error occured.
return FALSE;
}
}
Generalmicroseconds Pin
styve30-Nov-03 20:58
styve30-Nov-03 20:58 
GeneralRe: microseconds Pin
BaldwinMartin30-Nov-03 23:27
BaldwinMartin30-Nov-03 23:27 
GeneralRe: microseconds Pin
styve1-Dec-03 0:55
styve1-Dec-03 0:55 
GeneralRe: microseconds Pin
BaldwinMartin1-Dec-03 1:03
BaldwinMartin1-Dec-03 1:03 
QuestionHow to remove Client area in a single document application Pin
Anand Manikiam30-Nov-03 20:31
Anand Manikiam30-Nov-03 20:31 
AnswerRe: How to remove Client area in a single document application Pin
Prakash Nadar30-Nov-03 22:15
Prakash Nadar30-Nov-03 22:15 
Generalmessage box..... Pin
Best Friend30-Nov-03 20:09
Best Friend30-Nov-03 20:09 
GeneralRe: message box..... Pin
Shanmuga Sundar30-Nov-03 21:16
Shanmuga Sundar30-Nov-03 21:16 
GeneralWindow creation problem Pin
User 21559730-Nov-03 19:35
User 21559730-Nov-03 19:35 
GeneralRe: Window creation problem Pin
Antti Keskinen30-Nov-03 23:51
Antti Keskinen30-Nov-03 23:51 
GeneralRe: Window creation problem Pin
User 2155971-Dec-03 0:25
User 2155971-Dec-03 0:25 
Generalregd CFile Pin
karteek30-Nov-03 18:08
karteek30-Nov-03 18:08 
GeneralRe: regd CFile Pin
Antti Keskinen30-Nov-03 23:58
Antti Keskinen30-Nov-03 23:58 
GeneralActiveX spreadsheet Pin
DougW4830-Nov-03 16:51
DougW4830-Nov-03 16:51 
Questionhow to run.exe without visual c++ installed? Pin
Anonymous30-Nov-03 15:42
Anonymous30-Nov-03 15:42 
AnswerRe: how to run.exe without visual c++ installed? Pin
Prakash Nadar30-Nov-03 16:02
Prakash Nadar30-Nov-03 16:02 
GeneralRe: how to run.exe without visual c++ installed? Pin
BaldwinMartin30-Nov-03 23:17
BaldwinMartin30-Nov-03 23:17 

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.