fix wolfSSL_Init to only call new wolfCrypt_Init() once
This commit is contained in:
parent
a1d1155b0c
commit
54a0a3370a
57
src/ssl.c
57
src/ssl.c
@ -159,8 +159,15 @@ WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD* method)
|
||||
|
||||
WOLFSSL_ENTER("WOLFSSL_CTX_new");
|
||||
|
||||
if (initRefCount == 0)
|
||||
wolfSSL_Init(); /* user no longer forced to call Init themselves */
|
||||
if (initRefCount == 0) {
|
||||
/* user no longer forced to call Init themselves */
|
||||
int ret = wolfSSL_Init();
|
||||
if (ret != SSL_SUCCESS) {
|
||||
WOLFSSL_MSG("wolfSSL_Init failed");
|
||||
WOLFSSL_LEAVE("WOLFSSL_CTX_new", 0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (method == NULL)
|
||||
return ctx;
|
||||
@ -2337,33 +2344,35 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, buffer der, int type, int verify)
|
||||
|
||||
int wolfSSL_Init(void)
|
||||
{
|
||||
int ret = SSL_SUCCESS;
|
||||
|
||||
WOLFSSL_ENTER("wolfSSL_Init");
|
||||
|
||||
if (initRefCount == 0) {
|
||||
/* Initialize crypto for use with TLS connection */
|
||||
if (wolfCrypt_Init() != 0) {
|
||||
WOLFSSL_MSG("Bad wolfCrypt Init");
|
||||
return WC_INIT_E;
|
||||
}
|
||||
#ifndef NO_SESSION_CACHE
|
||||
if (InitMutex(&session_mutex) != 0)
|
||||
ret = BAD_MUTEX_E;
|
||||
#endif
|
||||
if (InitMutex(&count_mutex) != 0)
|
||||
ret = BAD_MUTEX_E;
|
||||
}
|
||||
if (ret == SSL_SUCCESS) {
|
||||
if (LockMutex(&count_mutex) != 0) {
|
||||
WOLFSSL_MSG("Bad Lock Mutex count");
|
||||
if (InitMutex(&session_mutex) != 0) {
|
||||
WOLFSSL_MSG("Bad Init Mutex session");
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
#endif
|
||||
if (InitMutex(&count_mutex) != 0) {
|
||||
WOLFSSL_MSG("Bad Init Mutex count");
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
|
||||
/* Initialize crypto for use with TLS connection */
|
||||
if (wolfcrypt_Init() != 0)
|
||||
ret = WC_INIT_E;
|
||||
|
||||
initRefCount++;
|
||||
UnLockMutex(&count_mutex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
if (LockMutex(&count_mutex) != 0) {
|
||||
WOLFSSL_MSG("Bad Lock Mutex count");
|
||||
return BAD_MUTEX_E;
|
||||
}
|
||||
|
||||
initRefCount++;
|
||||
UnLockMutex(&count_mutex);
|
||||
|
||||
return SSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -7352,8 +7361,10 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
|
||||
int wolfSSL_add_all_algorithms(void)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_add_all_algorithms");
|
||||
wolfSSL_Init();
|
||||
return SSL_SUCCESS;
|
||||
if (wolfSSL_Init() == SSL_SUCCESS)
|
||||
return SSL_SUCCESS;
|
||||
else
|
||||
return SSL_FATAL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ int benchmark_test(void *args)
|
||||
{
|
||||
#endif
|
||||
|
||||
wolfcrypt_Init();
|
||||
wolfCrypt_Init();
|
||||
|
||||
#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
|
||||
wolfSSL_Debugging_ON();
|
||||
|
@ -43,7 +43,7 @@
|
||||
/* Used to initialize state for wolfcrypt
|
||||
return 0 on success
|
||||
*/
|
||||
int wolfcrypt_Init()
|
||||
int wolfCrypt_Init()
|
||||
{
|
||||
#if WOLFSSL_CRYPT_HW_MUTEX
|
||||
/* If crypto hardware mutex protection is enabled, then initialize it */
|
||||
|
@ -170,7 +170,7 @@ WOLFSSL_LOCAL int LockMutex(wolfSSL_Mutex*);
|
||||
WOLFSSL_LOCAL int UnLockMutex(wolfSSL_Mutex*);
|
||||
|
||||
/* main crypto initialization function */
|
||||
WOLFSSL_API int wolfcrypt_Init(void);
|
||||
WOLFSSL_API int wolfCrypt_Init(void);
|
||||
|
||||
/* filesystem abstraction layer, used by ssl.c */
|
||||
#ifndef NO_FILESYSTEM
|
||||
|
Loading…
x
Reference in New Issue
Block a user