c - SSL_CTX_new:unable to load ssl2 md5 routines -


we having trouble running program built openssl. specific error encountering is: global error: ssl context init failed error:140a90f1:ssl routines:ssl_ctx_new:unable load ssl2 md5 routines.

the context c library being wrapped perl library using swig. error occurs when attempting connect https address using perl library.

for example, code cause error:

#these imports felt relevant problem use lwp::useragent; use http::request; use lwp::protocol::https; use io::socket::ssl;  sub test_can_connect_to_bitpay_api {   $uri = "https://www.google.com";   $pem = business::onlinepayment::bitpay::keyutils::bpgeneratepem();   $sin = business::onlinepayment::bitpay::keyutils::bpgeneratesinfrompem($pem);   $request = http::request->new(post => $uri);   $ua = lwp::useragent->new;   $response = $ua->request($request);   ok($response->is_success, "test connection"); } 

but same code not error if call bpgeneratesinfrompem() not made.

bpgeneratesinfrompem wrapper function in *.i file.

%inline %{   char *bpgeneratesinfrompem(char *pem) {     char *ret = malloc(sizeof(char)*36);     char *err = "error";     int errorcode;      errorcode = generatesinfrompem(pem, &ret);      if (errorcode == noerror) {       return ret;     } else {       return err;     }    } %} 

which calls c function:

int generatesinfrompem(char *pem, char **sin) {      char *pub =     calloc(67, sizeof(char));      u_int8_t *outbytespub = calloc(sha256_string, sizeof(u_int8_t));     u_int8_t *outbytesofstep1 = calloc(sha256_string, sizeof(u_int8_t));     u_int8_t *outbytesofstep3 = calloc(ripemd_and_padding_string, sizeof(u_int8_t));     u_int8_t *outbytesofstep4a = calloc(sha256_string, sizeof(u_int8_t));      char *step1 =   calloc(sha256_hex_string, sizeof(char));     char *step2 =   calloc(ripemd_hex_string, sizeof(char));     char *step3 =   calloc(ripemd_and_padding_hex_string, sizeof(char));     char *step4a =  calloc(sha256_hex_string, sizeof(char));     char *step4b =  calloc(sha256_hex_string, sizeof(char));     char *step5 =   calloc(checksum_string, sizeof(char));     char *step6 =   calloc(ripemd_and_padding_hex + checksum_string, sizeof(char));      char *base58ofstep6 = calloc(sin_string, sizeof(char));      getpublickeyfrompem(pem, &pub);     pub[66] = '\0';      createdatawithhexstring(pub, &outbytespub);     digestofbytes(outbytespub, &step1, "sha256", sha256_string);     step1[64] = '\0';      createdatawithhexstring(step1, &outbytesofstep1);     digestofbytes(outbytesofstep1, &step2, "ripemd160", sha256_digest_length);     step2[40] = '\0';      memcpy(step3, "0f02", 4);     memcpy(step3+4, step2, ripemd_hex);     step3[44] = '\0';      createdatawithhexstring(step3, &outbytesofstep3);     digestofbytes(outbytesofstep3, &step4a, "sha256", ripemd_and_padding);     step4a[64] = '\0';      createdatawithhexstring(step4a, &outbytesofstep4a);     digestofbytes(outbytesofstep4a, &step4b, "sha256", sha256_digest_length);     step4b[64] = '\0';      memcpy(step5, step4b, checksum);      sprintf(step6, "%s%s", step3, step5);     step6[ripemd_and_padding_hex + checksum] = '\0';      base58encode(step6, base58ofstep6);     base58ofstep6[sin] = '\0';     memcpy(*sin, base58ofstep6, sin_string);      free(pub);     free(step1);     free(step2);     free(step3);     free(step4a);     free(step4b);     free(step5);     free(step6);     free(base58ofstep6);      free(outbytespub);     free(outbytesofstep1);     free(outbytesofstep3);     free(outbytesofstep4a);     return noerror; } 

which calls digestofbytes() method:

static int digestofbytes(uint8_t *message, char **output, char *type, int inlength) {     evp_md_ctx *mdctx;     const evp_md *md;     unsigned char md_value[evp_max_md_size];     unsigned int md_len, i;      openssl_add_all_digests();      md = evp_get_digestbyname(type);     mdctx = evp_md_ctx_create();     evp_digestinit_ex(mdctx, md, null);     evp_digestupdate(mdctx, message, inlength);     evp_digestfinal_ex(mdctx, md_value, &md_len);     evp_md_ctx_destroy(mdctx);      char *digest = calloc((md_len*2) + 1, sizeof(char));     for(i = 0; < md_len; i++){       sprintf(&digest[2*i], "%02x", md_value[i]);     };     digest[md_len * 2] = '\0';     memcpy(*output, digest, strlen(digest));     free(digest);     /* call once before exit. */     evp_cleanup();     return 0; } 

there seems possibility being caused not releasing resources in our c library, looks freeing memory can freed. why seeing conflict?

our temporary, , bad, solution problem eliminate call evp_cleanup() in digestofbytes() method.

what apparently happening this: perl libraries importing use openssl, , load tables through openssl_add_all_x. because evp_cleanup() global, perl libraries (probably lwp::protocol::https) couldn't find tables of algorithms when went them up.

while works, i'd prefer safer... not cleaning seems sloppy solution.


Comments

Popular posts from this blog

Upgrade php version of xampp not success -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -