curl / Mailing Lists / curl-library / Single Mail

curl-library

openSSL could not create a context

From: Tuan Nguyen <tuan.nguyen_at_veriksystems.com>
Date: Wed, 11 Jul 2018 12:32:08 +0700

Hi there,

I am using libCURL/7.56.1 OpenSSL/1.0.2g.

When I try about 100 times post/get request to https service, I got error
message:
*SSL: couldn't create a context:
error:140A90F1:lib(20):func(169):reason(241)

I trace to CURL code and found that bug was happened when fucntion
SSL_CTX_new() return NULL in ossl_connect_step1().

Keep digged into openssl library, I found that EVP_get_digestbyname()
return NULL because list digest is NULL, function EVP_cleanup() was called
before.

So I tried to work around by re-init digest list if NULL was detected after
calling SSL_CTX_new().

if(BACKEND->ctx)
    SSL_CTX_free(BACKEND->ctx);
  BACKEND->ctx = SSL_CTX_new(req_method);

  if(!BACKEND->ctx) {
    OpenSSL_add_all_digests();//Re-init digest list
    BACKEND->ctx = SSL_CTX_new(req_method);//re-create again
    if(!BACKEND->ctx) {
      failf(data, "SSL: couldn't create a context: %s",
            ossl_strerror(ERR_peek_error(), error_buffer,
sizeof(error_buffer)));
      return CURLE_OUT_OF_MEMORY;
    }
  }

And it work.
I just want to know that is it compatible?

Thanks

Tuan Nguyen

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-07-11