3333/***** Includes *****/
3434#include <stdio.h>
3535
36+ /* wolfSSL */
37+ #ifndef WOLFSSL_USER_SETTINGS
38+ #include <wolfssl/options.h>
39+ #endif
3640#include <wolfssl/wolfcrypt/sha256.h>
3741#include <wolfssl/wolfcrypt/cryptocb.h>
3842#include <wolfssl/wolfcrypt/ecc.h>
@@ -116,7 +120,7 @@ static unsigned int my_psk_client_cs_cb(struct WOLFSSL* ssl, const char* hint,
116120void mxc_wolfssl_create (int sockfd , WOLFSSL * * ssl )
117121{
118122 int ret ;
119- int exit_clean = 0 ;
123+ int exit_clean = 1 ;
120124
121125 /* declare wolfSSL objects */
122126 WOLFSSL_CTX * ctx = NULL ;
@@ -131,7 +135,6 @@ void mxc_wolfssl_create(int sockfd, WOLFSSL **ssl)
131135 /* Initialize wolfSSL */
132136 if ((ret = wolfSSL_Init ()) != WOLFSSL_SUCCESS ) {
133137 MXC_ERR_MSG ("ERROR: Failed to initialize the library\n" );
134- exit_clean = 1 ;
135138 goto exit ;
136139 }
137140
@@ -150,7 +153,6 @@ void mxc_wolfssl_create(int sockfd, WOLFSSL **ssl)
150153 if (ctx == NULL ) {
151154 MXC_ERR_MSG ("ERROR: failed to create WOLFSSL_CTX\n" );
152155 ret = -1 ;
153- exit_clean = 1 ;
154156 goto exit ;
155157 }
156158
@@ -164,14 +166,13 @@ void mxc_wolfssl_create(int sockfd, WOLFSSL **ssl)
164166 WOLFSSL_FILETYPE_PEM )) != WOLFSSL_SUCCESS ) {
165167 MXC_ERR_MSG ("ERROR: failed to load %s, please check the "
166168 "file.\n" , key_file );
167- exit_clean = 1 ;
168169 goto exit ;
169170 }
170171 }
171172#else
172173
173174#if defined (TEST_RSA )
174- ret = wolfSSL_CTX_use_PrivateKey_buffer (ctx , rsa_key_der_2048 ,
175+ ret = wolfSSL_CTX_use_PrivateKey_buffer (ctx , rsa_key_der_2048 ,
175176 sizeof (rsa_key_der_2048 ), WOLFSSL_FILETYPE_ASN1 );
176177#elif defined (HAVE_ECC )
177178 ret = wolfSSL_CTX_use_PrivateKey_buffer (ctx , ecc_key_der_256 ,
@@ -190,7 +191,6 @@ ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, rsa_key_der_2048,
190191 if (ciphersuite != NULL ) {
191192 if (wolfSSL_CTX_set_cipher_list (ctx , ciphersuite ) != WOLFSSL_SUCCESS ) {
192193 MXC_ERR_MSG ("Invalid cipher suite.\n" );
193- exit_clean = 1 ;
194194 goto exit ;
195195 }
196196 }
@@ -215,9 +215,10 @@ ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, rsa_key_der_2048,
215215 if ((* ssl = wolfSSL_new (ctx )) == NULL ) {
216216 MXC_ERR_MSG ("ERROR: failed to create WOLFSSL object\n" );
217217 ret = -1 ;
218- exit_clean = 1 ;
219218 goto exit ;
220219 }
220+
221+ exit_clean = 0 ;
221222exit :
222223 /* Cleanup and return */
223224 if (ctx != NULL )
@@ -298,7 +299,6 @@ int mxc_wolfssl_read(WOLFSSL* ssl)
298299 /* Print to stdout any data the server sends */
299300 MXC_DEBUG_MSG ("Server: %s\n" , buff );
300301 return ret ;
301- // ret = 0; /* success */
302302}
303303
304304void mxc_wolfssl_close (int sockfd , WOLFSSL * ssl )
0 commit comments