Hi
I was able to read the content data from the server using SSL_read and put back to the browser by using SSL_write. I don't know whether is a right approach or not. I have done the experiment in these two urls

1. https://s-static.ak.facebook.com/rsrc.php/z9Q0Q/hash/8yhim1ep.ico

2. https://s-static.ak.facebook.com/rsrc.php/z8OGI/hash/41j5eq4v.png

For the first try I got the response as follows and I was able to see the icon in my browser
   HTTP/1.1 200 OK
   Cache-Control: public, max-age=31536000
   Content-Length: 318
   Content-Type: image/x-icon
   Expires: Sat, 06 Aug 2011 06:58:14 -0700
   Last-Modified: Sat, 01 Jan 2000 00:00:00 GMT
   P3P: CP="DSP LAW"
   Pragma:
   X-Cnection: close
   Date: Fri, 06 Aug 2010 13:58:14 GMT

But for the second link, which is 42,565 bytes long, I am receiving the following output. I understood that there is more to do inorder to read the content data, which I am not sure about
   HTTP/1.1 200 OK
   Cache-Control: public, max-age=31536000
   Content-Length: 42565
   Content-Type: image/png
   Expires: Sat, 06 Aug 2011 07:04:17 -0700
   Last-Modified: Sat, 01 Jan 2000 00:00:00 GMT
   P3P: CP="DSP LAW"
   Pragma:
   X-Cnection: close
   Date: Fri, 06 Aug 2010 14:04:17 GMT

Can anybody tell me what else should I do inorder to read the content and show it the browser. The following are sending some code snippets


RequestSock = WSASocket(AF_INET,SOCK_STREAM,0,NULL,0,WSA_FLAG_OVERLAPPED);
            pHost = gethostbyname(pcTargetURL);
            memset(&ClientAddr,0,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;
             }

            SSL *Serverssl;
            Serverssl = SSL_new(m_pSSLCtx);
            SSL_set_fd(Serverssl, RequestSock);
           iRes = SSL_connect(Serverssl);
            if(iRes <= 0 )
            {
                     ERR_print_errors_fp(stderr);
                     cout << " connect Failed " << endl;
             }
              iRes = SSL_write(Serverssl,pcData, strlen(pcData));
            SSL_accept(Serverssl);
            do
            {
                     dwReadDataLen = SSL_read(Serverssl,pBuff,iBufferSize);
                      SSL_write(SourceSsl,pBuff,dwReadDataLen);
                      cout << "Read buffer \n" << pBuff << endl;
              } while(SSL_pending(Serverssl));


Thanks,
Raj
Rajmohan SK

----- Original Message ----- From: "Raj" <rajmo...@codework-solutions.com>
To: <openssl-users@openssl.org>
Sent: Friday, August 06, 2010 10:12 AM
Subject: Re: Man in the middle proxy - Not working


Hi

Can you send me some code snippet which shows how to commutate with webserver and read the content data

Thanks,
Raj
Rajmohan SK

----- Original Message ----- From: "Dave Thompson" <dthomp...@prinpay.com>
To: <openssl-users@openssl.org>
Sent: Friday, August 06, 2010 2:19 AM
Subject: RE: Man in the middle proxy - Not working


From: owner-openssl-us...@openssl.org On Behalf Of Raj
Sent: Thursday, 05 August, 2010 01:06

    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);

I don't know much about 'OVERLAPPED' in Windows, but I think
it's something like 'nonblocking' in Unix.

         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

At this point, the send probably hasn't actually happened.
And if you call [WSA]Recv and it returns, it almost certainly
hasn't actually been done either. You probably have to do
some kind of synchronization with the .hEvent, following
whatever Windows rules are applicable.

    FYI
        pcPort = 443
        pcTargetURL = L"www.facebook.com";
       pcData = "GET https://www.facebook.com HTTP/1.0\r\n\r\n"



______________________________________________________________________
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



______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to