Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket programming: Getting same response when request sent using openssl library
    primarykey
    data
    text
    <p>I am sending two different https header to different address on same host. I am getting the same response from both test() and test1() functions... It seems like something can be used only once.... thanks in advance :)</p> <pre><code>#include &lt;iostream&gt; #include &lt;errno.h&gt; #include &lt;unistd.h&gt; #include &lt;malloc.h&gt; #include &lt;string.h&gt; #include &lt;sys/socket.h&gt; #include &lt;resolv.h&gt; #include &lt;netdb.h&gt; #include &lt;openssl/ssl.h&gt; #include &lt;openssl/err.h&gt; #define FAIL -1 using namespace std; SSL_CTX* InitCTX(void); void test(SSL_CTX* ctx, int server); void test1(SSL_CTX* ctx, int server); int OpenConnection(char *hostname, int port); int main() { SSL_CTX *ctx; char *host = "academics.vit.ac.in"; char *port = "443"; SSL_library_init(); ctx = InitCTX(); int server = OpenConnection(host, atoi(port)); test(ctx, server); test1(ctx, server);// Both functions prints exactly same data return 0; } void test(SSL_CTX* ctx, int server) { char buf[9999]; int bytes; SSL *ssl; ssl = SSL_new(ctx); SSL_set_fd(ssl, server); if(SSL_connect(ssl) == FAIL) { ERR_print_errors_fp(stderr); } else { printf("Connected with %s encryption\n", SSL_get_cipher(ssl)); char*msg = "GET /student/captcha.asp HTTP/1.1\nHost: academics.vit.ac.in\nCookie: ASPSESSIONIDCUTRADAT=OMDEAOKCPOLOKCLJMPAALAJN\n\n"; SSL_write(ssl, msg, strlen(msg)); bytes = SSL_read(ssl, buf, sizeof(buf)); buf[bytes] = 0; printf("%s",buf); SSL_free(ssl); } } void test1(SSL_CTX* ctx, int server) { char buf[9999]; int bytes; SSL *ssl; ssl = SSL_new(ctx); SSL_set_fd(ssl, server); if(SSL_connect(ssl) == FAIL) { ERR_print_errors_fp(stderr); } else { printf("Connected with %s encryption\n", SSL_get_cipher(ssl)); char*msg = "GET / HTTP/1.1\nHost: academics.vit.ac.in\nCookie: ASPSESSIONIDCUTRADAT=OMDEAOKCPOLOKCLJMPAALAJN\n\n"; SSL_write(ssl, msg, strlen(msg)); bytes = SSL_read(ssl, buf, sizeof(buf)); buf[bytes] = 0; printf("%s",buf); SSL_free(ssl); } } SSL_CTX* InitCTX(void) { const SSL_METHOD *method; SSL_CTX *ctx; OpenSSL_add_all_algorithms(); SSL_load_error_strings(); method = SSLv3_client_method(); ctx = SSL_CTX_new(method); if ( ctx == NULL ) { ERR_print_errors_fp(stderr); abort(); } return ctx; } int OpenConnection(char *hostname, int port) { int sd; struct hostent *host; struct sockaddr_in addr; if ( (host = gethostbyname(hostname)) == NULL ) { perror(hostname); abort(); } sd = socket(PF_INET, SOCK_STREAM, 0); bzero(&amp;addr, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = *(long*)(host-&gt;h_addr); if ( connect(sd, (struct sockaddr*)&amp;addr, sizeof(addr)) != 0 ) { close(sd); perror(hostname); abort(); } return sd; } </code></pre> <p>The response i am getting is</p> <pre><code>Connected with RC4-SHA encryption HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Type: image/bmp Expires: Tue, 25 Jun 2013 08:27:30 GMT Server: Microsoft-IIS/7.0 Content-Disposition: inline; filename=captcha.bmp Set-Cookie: ASPSESSIONIDCUSTBBBT=BHEANFEAHBBCBIJDIBNOPDAI; secure; path=/ X-Powered-By: ASP.NET Date: Tue, 25 Jun 2013 08:28:30 GMT Connection: close Connected with (NONE) encryption HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Type: image/bmp Expires: Tue, 25 Jun 2013 08:27:30 GMT Server: Microsoft-IIS/7.0 Content-Disposition: inline; filename=captcha.bmp Set-Cookie: ASPSESSIONIDCUSTBBBT=BHEANFEAHBBCBIJDIBNOPDAI; secure; path=/ X-Powered-By: ASP.NET Date: Tue, 25 Jun 2013 08:28:30 GMT Connection: close </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload