//
// sub_E2DA90 from 0xe2da90 to 0xe2ee70 (5088 bytes)
//
// 2 xrefs:
// > sub_E2F488 @ 0xe2f5c4
// > sub_E2F6B4 @ 0xe2f7f0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:09:54 +0000
//
__int64 __fastcall sub_E2DA90(__int64 a1, int a2)
{
__int64 v2; // x22
__int64 v4; // x19
unsigned int v5; // s15
_QWORD *v6; // x26
unsigned __int64 v7; // x24
_BYTE *v8; // x28
int v9; // s10
unsigned int v10; // w27
const char *v11; // d9
const char *v12; // d13
const char *v13; // d12
const char *v14; // d11
const char *v15; // d14
__int64 result; // x0
__int64 v17; // x0
__int64 v18; // x0
__int64 v19; // x21
__int64 v20; // x0
int v21; // w0
__int64 v22; // x21
unsigned __int64 v23; // x24
__int64 v24; // x1
__int64 v25; // x3
__int64 v26; // x2
unsigned __int64 v27; // x0
unsigned __int64 v28; // x21
unsigned __int64 v29; // x1
unsigned __int64 v30; // x3
unsigned __int64 v31; // x2
_BOOL4 v32; // w3
char *v33; // x2
__int64 v34; // x0
int v35; // w21
__int64 v36; // x0
const char *v37; // x0
__int64 v38; // x21
const char *v39; // d8
__int64 v40; // x24
__int64 v41; // x26
__int64 v42; // x2
FILE *v43; // x0
__int64 v44; // x28
__int64 v45; // x0
__int64 v46; // x0
const char *v47; // x0
_BOOL4 v48; // w0
_BOOL4 v49; // w0
__int64 v50; // x0
__int64 cert_store; // x24
__int64 v52; // x0
__int64 v53; // x0
__int64 v54; // x0
const char *v55; // x0
const char *v56; // x1
const char *v57; // x3
__int64 v58; // x0
const char *v59; // x0
const char *v60; // x21
__int64 v61; // x1
_BOOL4 v62; // w0
const char *v63; // x2
const char *v64; // x3
__int64 v65; // x0
__int64 (__fastcall *v66)(__int64, _QWORD, _QWORD); // x3
unsigned int v67; // w21
__int64 v68; // x0
__int64 v69; // x21
__int64 v70; // x0
int v71; // w1
__int64 v72; // x21
__int64 v73; // x0
__int64 v74; // x19
__int64 v75; // x24
__int64 certificate; // x0
__int64 pubkey; // x28
__int64 privatekey; // x0
__int64 v79; // x0
const char *v80; // x0
int v81; // w28
int v82; // w0
const char *v83; // x2
const char *v84; // x3
__int64 v85; // x0
__int64 v86; // x0
const char *v87; // x0
__int64 v88; // x0
__int64 error; // x0
const char *v90; // x0
__int64 v91; // x0
const char *v92; // x0
__int64 method; // x28
__int64 v94; // x0
__int64 opener; // x0
__int64 v96; // x0
__int64 v97; // x0
__int64 closer; // x0
__int64 private_key; // x24
_BOOL4 v100; // w0
const char *v101; // x0
__int64 v102; // x28
FILE *stream; // [xsp+B0h] [xbp+B0h]
FILE *streama; // [xsp+B0h] [xbp+B0h]
unsigned int file; // [xsp+B8h] [xbp+B8h]
const char *v106; // [xsp+B8h] [xbp+B8h]
char *v107; // [xsp+B8h] [xbp+B8h]
__int64 v108; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v109; // [xsp+D0h] [xbp+D0h] BYREF
const char *v110; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v111; // [xsp+E0h] [xbp+E0h]
char buf; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v113; // [xsp+E9h] [xbp+E9h]
v2 = a2;
v4 = *(_QWORD *)a1;
v5 = *(_DWORD *)(a1 + 4 * (a2 + 152LL));
if ( *(_DWORD *)(a1 + 384) != 2 )
{
v6 = (_QWORD *)(v4 + 1160);
v7 = *(_QWORD *)(a1 + 824);
v8 = *(_BYTE **)(v4 + 1216);
v9 = *(_DWORD *)(v4 + 1264);
v10 = *(unsigned __int8 *)(a1 + 832);
v11 = *(const char **)(v4 + 1208);
v12 = *(const char **)(a1 + 848);
v13 = *(const char **)(a1 + 840);
v14 = *(const char **)(v4 + 1168);
LABEL_3:
v15 = *(const char **)(a1 + 192);
goto LABEL_4;
}
if ( *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
{
v6 = (_QWORD *)(v4 + 1160);
v7 = *(_QWORD *)(a1 + 824);
v9 = *(_DWORD *)(v4 + 1264);
v11 = *(const char **)(v4 + 1208);
v8 = *(_BYTE **)(v4 + 1216);
v12 = *(const char **)(a1 + 848);
v10 = *(unsigned __int8 *)(a1 + 832);
v13 = *(const char **)(a1 + 840);
v14 = *(const char **)(v4 + 1168);
goto LABEL_3;
}
v7 = *(_QWORD *)(a1 + 888);
v6 = (_QWORD *)(v4 + 1344);
v9 = *(_DWORD *)(v4 + 1448);
v11 = *(const char **)(v4 + 1392);
v8 = *(_BYTE **)(v4 + 1400);
v12 = *(const char **)(a1 + 912);
v10 = *(unsigned __int8 *)(a1 + 896);
v13 = *(const char **)(a1 + 904);
v14 = *(const char **)(v4 + 1352);
v15 = *(const char **)(a1 + 360);
LABEL_4:
if ( !byte_156282C )
{
if ( !(unsigned int)((__int64 (*)(void))RAND_status)() )
{
v17 = *(_QWORD *)(v4 + 1928);
if ( v17 )
{
file = RAND_load_file(v17, 1024);
if ( (unsigned int)((__int64 (*)(void))RAND_status)() )
{
result = file;
if ( file )
return result;
goto LABEL_5;
}
}
else
{
file = 0;
}
do
{
if ( !(unsigned int)RAND_bytes(&buf, 64) )
break;
v18 = RAND_add(&buf, 64, 32.0);
}
while ( !(unsigned int)RAND_status(v18) );
*(_BYTE *)(v4 + 2824) = 0;
RAND_file_name(v4 + 2824, 0x4000);
if ( !*(_BYTE *)(v4 + 2824) || (v34 = RAND_load_file(v4 + 2824, 1024), v35 = v34, !(unsigned int)RAND_status(v34)) )
{
sub_DF16E0(v4, "libcurl is now using a weak random seed!\n");
return 35;
}
result = v35 + file;
if ( (_DWORD)result )
return result;
goto LABEL_5;
}
byte_156282C = 1;
}
LABEL_5:
*v6 = 1;
if ( v7 > 7 )
{
sub_DF1848(v4, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
return 35;
}
switch ( (int)v7 )
{
case 0:
case 1:
case 4:
case 5:
case 6:
case 7:
v19 = TLS_client_method();
if ( *(_QWORD *)(a1 + 40 * v2 + 680) )
SSL_CTX_free();
v20 = SSL_CTX_new(v19);
*(_QWORD *)(a1 + 40 * v2 + 680) = v20;
if ( !v20 )
{
v36 = ERR_peek_error();
v37 = (const char *)ERR_error_string(v36, 0);
sub_DF1848(v4, "SSL: couldn't create a context: %s", v37);
return 27;
}
SSL_CTX_ctrl(v20, 33, 16, 0);
if ( *(_QWORD *)(v4 + 744) && *(_BYTE *)(v4 + 1576) )
{
SSL_CTX_set_msg_callback(*(_QWORD *)(a1 + 40 * v2 + 680), sub_E2AF44);
SSL_CTX_ctrl(*(_QWORD *)(a1 + 40 * v2 + 680), 16, 0, a1);
}
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v21 = *(unsigned __int8 *)(v4 + 1152) ^ 1;
else
v21 = *(unsigned __int8 *)(v4 + 1336) ^ 1;
v22 = 17407;
if ( !v21 )
v22 = 19455;
v23 = v7 - 2;
v24 = v22;
v25 = v22;
v26 = v22;
v27 = v22 & 0xFFFFFFFF0000FFFFLL | 0x82020000;
v28 = v22 & 0xFFFFFFFF0000FFFFLL | 0x9C020000;
v29 = v24 & 0xFFFFFFFF0000FFFFLL | 0x9A020000;
v30 = v25 & 0xFFFFFFFF0000FFFFLL | 0x8E020000;
v31 = v26 & 0xFFFFFFFF0000FFFFLL | 0x96020000;
if ( v23 <= 5 )
{
switch ( (int)v23 )
{
case 0:
goto LABEL_21;
case 1:
if ( v9 == 1 )
sub_DF16E0(v4, "Set version TLSv1.x for SRP authorisation\n", v31, v30);
v29 = v28;
goto LABEL_34;
case 2:
goto LABEL_34;
case 3:
v29 = v30;
goto LABEL_34;
case 4:
v29 = v31;
goto LABEL_34;
case 5:
sub_DF1848(v4, "OpenSSL was built without TLS 1.3 support", v31, v30);
result = 4;
break;
}
return result;
}
v29 = v27;
LABEL_34:
SSL_CTX_set_options(*(_QWORD *)(a1 + 40 * v2 + 680), v29, v31, v30);
if ( *(_BYTE *)(a1 + 983) )
SSL_CTX_set_next_proto_select_cb(*(_QWORD *)(a1 + 40 * v2 + 680), sub_E2B71C, a1);
if ( *(_BYTE *)(a1 + 984) )
{
buf = 8;
v113 = *(_QWORD *)"http/1.1";
sub_DF16E0(v4, "ALPN, offering %s\n", "http/1.1");
SSL_CTX_set_alpn_protos(*(_QWORD *)(a1 + 40 * v2 + 680), &buf, 9);
}
v32 = v11 != nullptr;
if ( !v8 && !v11 )
goto LABEL_40;
v38 = *(_QWORD *)(a1 + 40 * v2 + 680);
if ( *(_DWORD *)(a1 + 384) != 2 )
{
v39 = *(const char **)(v4 + 1224);
v107 = *(char **)(v4 + 1232);
LABEL_64:
v40 = *(_QWORD *)(v4 + 1240);
goto LABEL_65;
}
if ( *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
{
v107 = *(char **)(v4 + 1232);
v39 = *(const char **)(v4 + 1224);
goto LABEL_64;
}
v39 = *(const char **)(v4 + 1408);
v107 = *(char **)(v4 + 1416);
v40 = *(_QWORD *)(v4 + 1424);
LABEL_65:
v41 = *(_QWORD *)a1;
if ( v8 && *v8 && (v48 = sub_E0A69C(v8, "PEM"), v32 = v11 != nullptr, !v48) )
{
v49 = sub_E0A69C(v8, "DER");
v42 = 2;
v32 = v11 != nullptr;
if ( !v49 )
{
if ( sub_E0A69C(v8, "ENG") )
{
v42 = 42;
if ( !v40 )
goto LABEL_82;
goto LABEL_70;
}
v100 = sub_E0A69C(v8, "P12");
v32 = v11 != nullptr;
if ( v100 )
v42 = 43;
else
v42 = 0xFFFFFFFFLL;
}
}
else
{
v42 = 1;
}
if ( v32 )
{
if ( !v40 )
{
LABEL_71:
if ( (_DWORD)v42 == 2 )
{
if ( (unsigned int)SSL_CTX_use_certificate_file(v38, v11) != 1 )
{
v58 = ((__int64 (*)(void))ERR_get_error)();
v59 = (const char *)ERR_error_string(v58, 0);
sub_DF1848(
v41,
"could not load ASN1 client certificate, OpenSSL error %s, (no key found, wrong pass phrase, or wrong file format?)",
v59);
return 58;
}
goto LABEL_101;
}
if ( (int)v42 <= 2 )
{
if ( (_DWORD)v42 != 1 )
{
sub_DF1848(v41, "not supported file type '%s' for certificate", v8);
return 58;
}
if ( (unsigned int)SSL_CTX_use_certificate_chain_file(v38, v11) != 1 )
{
v54 = ((__int64 (*)(void))ERR_get_error)();
v55 = (const char *)ERR_error_string(v54, 0);
sub_DF1848(
v41,
"could not load PEM client certificate, OpenSSL error %s, (no key found, wrong pass phrase, or wrong file format?)",
v55);
return 58;
}
goto LABEL_101;
}
if ( (_DWORD)v42 != 42 )
{
v110 = nullptr;
v43 = fopen(v11, "rb");
if ( !v43 )
{
sub_DF1848(v41, "could not open PKCS12 file '%s'", v11);
return 58;
}
streama = v43;
v44 = d2i_PKCS12_fp(v43, 0);
v45 = fclose(streama);
if ( !v44 )
{
sub_DF1848(v41, "error reading PKCS12 file '%s'", v11);
return 58;
}
PKCS12_PBE_add(v45);
if ( !(unsigned int)PKCS12_parse(v44, v40, &v109, &v108, &v110) )
{
v46 = ((__int64 (*)(void))ERR_get_error)();
v47 = (const char *)ERR_error_string(v46, 0);
sub_DF1848(v41, "could not parse PKCS12 file, check password, OpenSSL error %s", v47);
PKCS12_free(v44);
return 58;
}
PKCS12_free(v44);
if ( (unsigned int)SSL_CTX_use_certificate(v38) == 1 )
{
if ( (unsigned int)SSL_CTX_use_PrivateKey(v38, v109) == 1 )
{
if ( (unsigned int)SSL_CTX_check_private_key(v38) )
{
v101 = v110;
if ( v110 )
{
while ( (unsigned int)OPENSSL_sk_num(v101) )
{
v102 = OPENSSL_sk_pop(v110);
if ( !SSL_CTX_ctrl(v38, 14, 0, v102) )
{
X509_free(v102);
sub_DF1848(v41, "cannot add certificate to certificate chain");
goto LABEL_165;
}
if ( !(unsigned int)SSL_CTX_add_client_CA(v38, v102) )
{
sub_DF1848(v41, "cannot add certificate to client CA list");
goto LABEL_165;
}
v101 = v110;
}
}
EVP_PKEY_free(v109);
X509_free(v108);
OPENSSL_sk_pop_free(v110, X509_free);
if ( !v107 )
goto LABEL_154;
if ( !*v107 )
goto LABEL_154;
v81 = 1;
if ( sub_E0A69C(v107, "PEM") )
goto LABEL_154;
goto LABEL_167;
}
sub_DF1848(v41, "private key from PKCS12 file '%s' does not match certificate in same file", v11);
}
else
{
sub_DF1848(v41, "unable to use private key from PKCS12 file '%s'", v11);
}
}
else
{
v79 = ((__int64 (*)(void))ERR_get_error)();
v80 = (const char *)ERR_error_string(v79, 0);
sub_DF1848(v41, "could not load PKCS12 client certificate, OpenSSL error %s", v80);
}
LABEL_165:
EVP_PKEY_free(v109);
X509_free(v108);
OPENSSL_sk_pop_free(v110, X509_free);
return 58;
}
LABEL_82:
v50 = *(_QWORD *)(v41 + 35912);
if ( !v50 )
{
sub_DF1848(v41, "crypto engine not set, can't load certificate", v42);
return 58;
}
v110 = v11;
v111 = 0;
if ( !(unsigned int)ENGINE_ctrl(v50, 13) )
{
sub_DF1848(v41, "ssl engine does not support loading certificates");
return 58;
}
if ( !(unsigned int)ENGINE_ctrl_cmd(*(_QWORD *)(v41 + 35912), "LOAD_CERT_CTRL", 0, &v110, 0, 1) )
{
v91 = ((__int64 (*)(void))ERR_get_error)();
v92 = (const char *)ERR_error_string(v91, 0);
sub_DF1848(v41, "ssl engine cannot load client cert with id '%s' [%s]", v11, v92);
return 58;
}
if ( !v111 )
{
sub_DF1848(v41, "ssl engine didn't initialized the certificate properly.");
return 58;
}
if ( (unsigned int)SSL_CTX_use_certificate(v38) != 1 )
{
sub_DF1848(v41, "unable to set client certificate");
X509_free(v111);
return 58;
}
X509_free(v111);
LABEL_101:
if ( !v107 || !*v107 || (v81 = 0, sub_E0A69C(v107, "PEM")) )
{
v56 = v39;
if ( !v39 )
v56 = v11;
v39 = v56;
if ( (unsigned int)SSL_CTX_use_PrivateKey_file(v38) == 1 )
goto LABEL_154;
if ( v107 )
v57 = v107;
else
v57 = "PEM";
goto LABEL_108;
}
LABEL_167:
if ( !sub_E0A69C(v107, "DER") )
{
if ( sub_E0A69C(v107, "ENG") )
{
if ( !*(_QWORD *)(v41 + 35912) )
{
sub_DF1848(v41, "crypto engine not set, can't load private key");
return 58;
}
method = UI_create_method("curl user interface");
if ( !method )
{
sub_DF1848(v41, "unable do create OpenSSL user-interface method", v41 + 0x8000);
return 58;
}
v94 = ((__int64 (*)(void))UI_OpenSSL)();
opener = UI_method_get_opener(v94);
v96 = UI_method_set_opener(method, opener);
v97 = UI_OpenSSL(v96);
closer = UI_method_get_closer(v97);
UI_method_set_closer(method, closer);
UI_method_set_reader(method, sub_E2B298);
UI_method_set_writer(method, sub_E2B228);
private_key = ENGINE_load_private_key(*(_QWORD *)(v41 + 35912), v39, method, v40);
UI_destroy_method(method);
if ( !private_key )
{
sub_DF1848(v41, "failed to load private key from crypto engine");
return 58;
}
if ( (unsigned int)SSL_CTX_use_PrivateKey(v38, private_key) != 1 )
{
sub_DF1848(v41, "unable to set private key");
EVP_PKEY_free(private_key);
return 58;
}
EVP_PKEY_free(private_key);
}
else
{
if ( !sub_E0A69C(v107, "P12") )
{
sub_DF1848(v41, "not supported file type for private key");
return 58;
}
if ( !v81 )
{
sub_DF1848(v41, "file type P12 for private key not supported");
return 58;
}
}
goto LABEL_154;
}
v82 = SSL_CTX_use_PrivateKey_file(v38);
v57 = v107;
if ( v82 == 1 )
{
LABEL_154:
v75 = SSL_new(v38);
if ( !v75 )
{
sub_DF1848(v41, "unable to create an SSL structure");
return 58;
}
certificate = SSL_get_certificate();
v108 = certificate;
if ( certificate )
{
pubkey = X509_get_pubkey(certificate);
privatekey = SSL_get_privatekey(v75);
EVP_PKEY_copy_parameters(pubkey, privatekey);
EVP_PKEY_free(pubkey);
}
SSL_free(v75);
if ( !(unsigned int)SSL_CTX_check_private_key(v38) )
{
sub_DF1848(v41, "Private key does not match the certificate public key");
return 58;
}
goto LABEL_40;
}
LABEL_108:
sub_DF1848(v41, "unable to set private key file: '%s' type %s", v39, v57);
return 58;
}
LABEL_70:
stream = (FILE *)v42;
SSL_CTX_set_default_passwd_cb_userdata(v38, v40);
SSL_CTX_set_default_passwd_cb(v38, sub_E2B6A8);
v42 = (__int64)stream;
goto LABEL_71;
}
LABEL_40:
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v33 = *(char **)(a1 + 880);
else
v33 = *(char **)(a1 + 944);
if ( !v33 )
v33 = "ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH";
v106 = v33;
if ( !(unsigned int)SSL_CTX_set_cipher_list(*(_QWORD *)(a1 + 40 * v2 + 680), v33) )
{
sub_DF1848(v4, "failed setting cipher list: %s", v106);
return 59;
}
sub_DF16E0(v4, "Cipher selection: %s\n", v106);
if ( v9 == 1 )
{
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v60 = *(const char **)(v4 + 1248);
else
v60 = *(const char **)(v4 + 1432);
sub_DF16E0(v4, "Using TLS-SRP username: %s\n", v60);
if ( !(unsigned int)SSL_CTX_set_srp_username(*(_QWORD *)(a1 + 40 * v2 + 680), v60) )
{
sub_DF1848(v4, "Unable to set SRP user name");
return 43;
}
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v61 = *(_QWORD *)(v4 + 1256);
else
v61 = *(_QWORD *)(v4 + 1440);
if ( !(unsigned int)SSL_CTX_set_srp_password(*(_QWORD *)(a1 + 40 * v2 + 680), v61) )
{
sub_DF1848(v4, "failed setting SRP password");
return 43;
}
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v62 = *(_QWORD *)(a1 + 880) == 0;
else
v62 = *(_QWORD *)(a1 + 944) == 0;
if ( v62 )
{
sub_DF16E0(v4, "Setting cipher list SRP\n");
if ( !(unsigned int)SSL_CTX_set_cipher_list(*(_QWORD *)(a1 + 40 * v2 + 680), "SRP") )
{
sub_DF1848(v4, "failed setting SRP cipher list");
return 59;
}
}
}
if ( v13 || v12 )
{
if ( (unsigned int)SSL_CTX_load_verify_locations(*(_QWORD *)(a1 + 40 * v2 + 680), v12, v13) )
{
sub_DF16E0(v4, "successfully set certificate verify locations:\n");
}
else
{
if ( v10 )
{
v63 = v12;
if ( !v12 )
v63 = "none";
v64 = v13;
if ( !v13 )
v64 = "none";
sub_DF1848(v4, "error setting certificate verify locations:\n CAfile: %s\n CApath: %s", v63, v64);
return 77;
}
sub_DF16E0(v4, "error setting certificate verify locations, continuing anyway:\n");
}
v83 = v12;
if ( !v12 )
v83 = "none";
v84 = v13;
if ( !v13 )
v84 = "none";
sub_DF16E0(v4, " CAfile: %s\n CApath: %s\n", v83, v84);
}
if ( v14 )
{
cert_store = SSL_CTX_get_cert_store(*(_QWORD *)(a1 + 40 * v2 + 680));
v52 = X509_LOOKUP_file();
v53 = X509_STORE_add_lookup(cert_store, v52);
if ( !v53 || !(unsigned int)X509_load_crl_file(v53, v14, 1) )
{
sub_DF1848(v4, "error loading CRL file: %s", v14);
return 82;
}
sub_DF16E0(v4, "successfully load CRL file:\n");
v65 = SSL_CTX_get_cert_store(*(_QWORD *)(a1 + 40 * v2 + 680));
X509_STORE_set_flags(v65, 12);
sub_DF16E0(v4, " CRLfile: %s\n", v14);
}
SSL_CTX_set_verify(*(_QWORD *)(a1 + 40 * v2 + 680), v10, 0);
v66 = *(__int64 (__fastcall **)(__int64, _QWORD, _QWORD))(v4 + 1184);
if ( v66 && (v67 = v66(v4, *(_QWORD *)(a1 + 40 * v2 + 680), *(_QWORD *)(v4 + 1192))) != 0 )
{
sub_DF1848(v4, "error signaled by ssl ctx callback");
return v67;
}
else
{
v68 = *(_QWORD *)(a1 + 40 * v2 + 688);
if ( v68 )
SSL_free(v68);
v69 = a1 + 40 * v2;
v70 = SSL_new(*(_QWORD *)(v69 + 680));
*(_QWORD *)(v69 + 688) = v70;
if ( v70 )
{
if ( *(_DWORD *)(a1 + 384) != 2 || *(_DWORD *)(a1 + 40LL * (*(_DWORD *)(a1 + 612) != -1) + 748) == 2 )
v71 = *(unsigned __int8 *)(a1 + 834);
else
v71 = *(unsigned __int8 *)(a1 + 898);
if ( v71 )
SSL_ctrl(v70, 65, 1, 0);
SSL_set_connect_state();
*(_QWORD *)(a1 + 40 * v2 + 696) = 0;
if ( !inet_pton(2, v15, &buf)
&& !inet_pton(10, v15, &buf)
&& !SSL_ctrl(*(_QWORD *)(a1 + 40 * v2 + 688), 55, 0, v15) )
{
sub_DF16E0(v4, "WARNING: failed to configure server name indication (SNI) TLS extension\n");
}
if ( *(_BYTE *)(v4 + 1456) )
{
v110 = nullptr;
sub_E3025C(a1);
if ( !(unsigned __int8)sub_E302A0(a1, &v110, 0, (unsigned int)v2) )
{
if ( !(unsigned int)SSL_set_session(*(_QWORD *)(a1 + 40 * v2 + 688), v110) )
{
v88 = sub_E30280(a1);
error = ERR_get_error(v88);
v90 = (const char *)ERR_error_string(error, 0);
sub_DF1848(v4, "SSL: SSL_set_session failed: %s", v90);
return 35;
}
sub_DF16E0(v4, "SSL re-using session ID\n");
}
sub_E30280(a1);
}
v72 = a1 + 40 * v2;
if ( *(_BYTE *)(v72 + 744) )
{
v73 = BIO_f_ssl();
v74 = BIO_new(v73);
BIO_ctrl(v74, 109, 0, *(_QWORD *)(v72 + 768));
SSL_set_bio(*(_QWORD *)(v72 + 688), v74, v74);
}
else
{
v85 = SSL_set_fd(*(_QWORD *)(v72 + 688), v5);
if ( !(_DWORD)v85 )
{
v86 = ERR_get_error(v85);
v87 = (const char *)ERR_error_string(v86, 0);
sub_DF1848(v4, "SSL: SSL_set_fd failed: %s", v87);
return 35;
}
}
*(_DWORD *)(a1 + 40 * v2 + 672) = 1;
return 0;
}
sub_DF1848(v4, "SSL: couldn't create a context (handle)!");
return 27;
}
case 2:
LABEL_21:
sub_DF1848(v4, "OpenSSL was built without SSLv2 support");
return 4;
case 3:
sub_DF1848(v4, "OpenSSL was built without SSLv3 support");
return 4;
}
}