from the “very rude manual” that you mentioned, I managed to achieve, before successful SSL confirmation, between the Mozilla web browser and my server (encoded in c). But after SSL_accept, when I try to use SSL_read to get the browser header of the part, I get unnecessary values and bytes read are zero. below code, calling SSL_accept is successful, but SSL_read is not ..
if(SSL_set_fd(ssl, client_s)<0) printf("\n error in assigning socket to SSL:"); else printf("\n The socket has been assigned to SSL Structure"); /* Perform SSL Handshake on the SSL server */ err = SSL_accept(ssl); printf("\n Value of err is %d",err); RETURN_ERR(err,"SSL_accept"); if(err==1) printf("\n The ssl connection/Handshake has been successful"); else printf("\n The ssl connection was not successful"); /* Informational output (optional) */ printf("\n SSL connection using %s\n", SSL_get_cipher (ssl)); /*receive the data from the client*/ //err = SSL_accept(ssl); while(i<5) { err = SSL_read(ssl, in_buf, strlen(in_buf)); printf("\n value of err is %d",err); RETURN_ERR(err,"SSL_read"); printf("\n The details from the server is\n: %s,\n Bytes Read : %d",in_buf,err); if(err<0) printf("\n Not Successfully received clients information"); i++; } err = SSL_shutdown(ssl); /* Terminate communication on a socket */ err = close(server_s); /* Free the SSL structure */ SSL_free(ssl); /* Free the SSL_CTX structure */ SSL_CTX_free(ctx); return(0); }
source share