//
// ssl_verify_cert_chain from 0x9a63f4 to 0x9a6630 (572 bytes)
//
// 3 xrefs:
// > tls_process_server_certificate @ 0x9b60c8
// > tls_process_client_certificate @ 0x9c1058
// > ??> @ 0x74cdc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:06:50 +0000
//
int __fastcall ssl_verify_cert_chain(_DWORD *a1, int a2)
{
int v5; // r7
int v6; // r6
int v7; // r0
int v8; // r5
int v9; // r7
int security_level; // r0
int v11; // r0
const char *v12; // r1
int v13; // r2
int (__fastcall *v14)(int, _DWORD); // r3
int v15; // r8
if ( !a2 )
return 0;
if ( !OPENSSL_sk_num(a2) )
return 0;
v5 = *(_DWORD *)(a1[50] + 204);
if ( !v5 )
v5 = *(_DWORD *)(a1[69] + 12);
v6 = X509_STORE_CTX_new();
if ( v6 )
{
v7 = OPENSSL_sk_value(a2, 0);
v8 = X509_STORE_CTX_init(v6, v5, v7, a2);
if ( v8 )
{
v9 = X509_STORE_CTX_get0_param(v6);
security_level = SSL_get_security_level(a1);
X509_VERIFY_PARAM_set_auth_level(v9, security_level);
X509_STORE_CTX_set_flags(v6, *(_DWORD *)(a1[50] + 16) & 0x30000);
v11 = SSL_get_ex_data_X509_STORE_CTX_idx();
if ( X509_STORE_CTX_set_ex_data(v6, v11, a1) )
{
if ( OPENSSL_sk_num(a1[33]) > 0 )
X509_STORE_CTX_set0_dane(v6, a1 + 32);
v12 = "ssl_server";
if ( a1[7] )
v12 = "ssl_client";
X509_STORE_CTX_set_default(v6, v12);
X509_VERIFY_PARAM_set1(v9, a1[31]);
if ( a1[63] )
X509_STORE_CTX_set_verify_cb(v6);
v13 = a1[69];
v14 = *(int (__fastcall **)(int, _DWORD))(v13 + 100);
if ( v14 )
v8 = v14(v6, *(_DWORD *)(v13 + 104));
else
v8 = X509_verify_cert(v6);
a1[71] = X509_STORE_CTX_get_error(v6);
OPENSSL_sk_pop_free(a1[70], X509_free);
a1[70] = 0;
if ( X509_STORE_CTX_get0_chain(v6) )
{
v15 = X509_STORE_CTX_get1_chain(v6);
a1[70] = v15;
if ( !v15 )
{
ERR_put_error(20, 207, 65, "ssl/ssl_cert.c", 447);
v8 = 0;
}
}
X509_VERIFY_PARAM_move_peername(a1[31], v9);
}
else
{
v8 = 0;
}
}
else
{
ERR_put_error(20, 207, 11, "ssl/ssl_cert.c", 399);
}
X509_STORE_CTX_free(v6);
return v8;
}
else
{
ERR_put_error(20, 207, 65, "ssl/ssl_cert.c", 393);
return 0;
}
}