Fixed client-psk-resume error in which it did not resume with last session

pull/50/head
Conner 2017-05-26 10:50:00 -06:00
parent 9adb1a757f
commit cc5286594d
2 changed files with 6 additions and 7 deletions

View File

@ -208,17 +208,17 @@ Session resumption allows a client/server pair to re-use previously generated cr
3. Now we are ready to reconnect and start a new socket but we are going to reuse the session id to make things go a little faster.
sockfd = socket(AF_INET, SOCK_STREAM, 0);
sock = socket(AF_INET, SOCK_STREAM, 0);
/* connect to the socket */
ret = connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
ret = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
if (ret != 0){
return 1;
}
/* set the session ID to connect to the server */
wolfSSL_set_fd(sslResume, sockfd);
wolfSSL_set_fd(sslResume, sock);
wolfSSL_set_session(sslResume, session);
4. Check if the connect was successful.
@ -245,7 +245,7 @@ Session resumption allows a client/server pair to re-use previously generated cr
wolfSSL_shutdown(sslResume);
/* shut down socket */
close(sockfd);
close(sock);
/* clean up */
wolfSSL_free(sslResume);

View File

@ -158,10 +158,9 @@ int main(int argc, char **argv){
/* close connection */
close(sockfd);
/* cleanup */
/* cleanup without wolfSSL_Cleanup() for now */
wolfSSL_free(ssl);
wolfSSL_CTX_free(ctx);
wolfSSL_Cleanup();
/*
* resume session, start new connection and socket
@ -206,7 +205,7 @@ int main(int argc, char **argv){
/* shut down socket */
close(sock);
/* clean up */
/* clean up now with wolfSSL_Cleanup() */
wolfSSL_free(sslResume);
wolfSSL_CTX_free(ctx);
wolfSSL_Cleanup();