Hi
I will describe my code snippet below
The module for connecting to server
SOCKET RequestSock;
SOCKADDR_IN ClientAddr;
RequestSock =
WSASocket(AF_INET,SOCK_STREAM,0,NULL,0,WSA_FLAG_OVERLAPPED);
pHost = gethostbyname(pcTargetURL);
memset(&ClientAddr,0,sizeof(ClientAddr));
int iAddrLen = sizeof(ClientAddr);
ClientAddr.sin_family = AF_INET;
memcpy(&ClientAddr.sin_addr,pHost->h_addr, pHost->h_length);
ClientAddr.sin_port = htons(atoi(pcPort));
if(0 != connect(RequestSock,(SOCKADDR *)&ClientAddr,
sizeof(SOCKADDR_IN)))
{
closesocket(RequestSock); // Connection failed
return false;
}
WSAOVERLAPPED SendOverlapped;
DWORD dwSendDataLen = 0;
WSABUF ClientRequestBuf;
WSAEVENT SendEvent[1];
ClientRequestBuf.buf = pcData;
ClientRequestBuf.len = strlen(pcData);
SendEvent[0] = WSACreateEvent();
SendOverlapped.hEvent = SendEvent[0];
iRes =
WSASend(RequestSock,&ClientRequestBuf,1,&dwSendDataLen,dwFlag,&SendOverlapped,NULL);
// Sending data to the server
FYI
pcPort = 443
pcTargetURL = L"www.facebook.com";
pcData = "GET https://www.facebook.com HTTP/1.0\r\n\r\n"
Thanks, Raj Rajmohan SK
----- Original Message -----
From: "Dave Thompson" <dthomp...@prinpay.com>
To: <openssl-users@openssl.org>
Sent: Thursday, August 05, 2010 7:48 AM
Subject: RE: Man in the middle proxy - Not working
From: owner-openssl-us...@openssl.org On Behalf Of Raj
Sent: Wednesday, 04 August, 2010 01:09
Thanks for all the response
1. I was able to do the handshaking successfully with
the browser.
On receiving the request from the browser I will send "HTTP
OK " response
back to the browser, I was able to do the handshaking and
read the actual
GET request.
To be clear: I interpret you received CONNECT, sent OK,
did SSL handshake between browser and you (SSL_accept),
then SSL_read (data which is a) GET request.
2. Then I create a new socket to establish the
connection with
server. The connection was successful.
Sends the request to the server
Reads the request from the server
(Obviously you mean read response.)
When I read the response from the server it always return
empty. I don't
know what went wrong here. I am reading the data from the
socket using
'recv' function. Can anybody tell me what went wrong
Is the connection to the server clear, or SSL?
If SSL, you must use SSL_{connect,write,read,etc} throughout,
with a different SSL* pointer than the one for the client side.
And check for errors and report them etc.
If clear, either:
- you did the send and/or recv wrong; we'd have to look at
your code, which you should simplify/trim as much as possible.
- the server didn't like the request you sent, or you,
strongly enough it just closed the connection. For HTTP
this should be rare; most issues with the actual request
(such as bad method or resource, unauthorized, bad or
prohibited or required body, etc.) have defined HTTP
error responses. Something like a firewall or frontend
that works at the TCP level might just disconnect you,
although in my experience they usually block or reject
the initial connection (SYN) or break abruptly (RST),
either of which appears to your program as an error
return (canonically -1, not 0).
Can you contact the people operating the server, and
can they check their logs around the time of your attempt?
Can you connect to the server from a browser on the machine
running your proxy, or at one nearby on the same subnet?
In clear, SSL, or both? And do a GET like the one you are
(receiving and) forwarding from your client? Successfully?
Can you run a monitor like tcpdump or wireshark while running
your program, to see what was actually sent to the server
and confirm if any data or what flags came back?
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org