//
// X509_STORE_add_cert from 0xde8058 to 0xde8160 (264 bytes)
//
// 6 xrefs:
// > ssl_build_cert_chain @ 0xd3b874
// > ssl_build_cert_chain @ 0xd3b8c4
// > X509_load_cert_file @ 0xde4a70
// > X509_load_cert_file @ 0xde4b00
// > X509_load_cert_crl_file @ 0xde4d98
// > ??> @ 0xbc8b0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall X509_STORE_add_cert(__int64 a1, __int64 a2)
{
_DWORD *v4; // x0
_QWORD *v5; // x22
unsigned int v6; // w19
int v7; // w21
if ( !a2 )
return 0;
v4 = X509_OBJECT_new();
v5 = v4;
if ( !v4 )
return 0;
v6 = 1;
*((_QWORD *)v4 + 1) = a2;
*v4 = 1;
X509_OBJECT_up_ref_count((__int64)v4);
CRYPTO_THREAD_write_lock(*(pthread_rwlock_t **)(a1 + 144));
if ( X509_OBJECT_retrieve_match(*(unsigned int **)(a1 + 8), (__int64)v5) )
{
v7 = 1;
ERR_put_error(11, 124, 101, (__int64)"crypto/x509/x509_lu.c", 326);
CRYPTO_THREAD_unlock(*(pthread_rwlock_t **)(a1 + 144));
}
else
{
v7 = OPENSSL_sk_push(*(int **)(a1 + 8), (__int64)v5);
CRYPTO_THREAD_unlock(*(pthread_rwlock_t **)(a1 + 144));
if ( v7 )
return v6;
}
v6 = 0;
X509_OBJECT_free(v5);
if ( v7 )
return v6;
ERR_put_error(11, 124, 65, (__int64)"crypto/x509/x509_lu.c", 338);
return 0;
}