//
// X509_load_cert_file from 0xde4984 to 0xde4b38 (436 bytes)
//
// 4 xrefs:
// > sub_DE3F88 @ 0xde419c
// > X509_load_cert_crl_file @ 0xde4d1c
// > sub_DE4E3C @ 0xde4e70
// > ??> @ 0x8a588
//
// 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_load_cert_file(__int64 a1, __int64 a2, int a3)
{
void *v6; // x0
__int64 v7; // x0
_QWORD *v8; // x22
__int64 bio_X509_AUX; // x19
unsigned int v10; // w20
if ( !a2 )
return 1;
v6 = BIO_s_file();
v7 = BIO_new((__int64)v6);
v8 = (_QWORD *)v7;
if ( v7 && (int)BIO_ctrl(v7, 0x6Cu, 3, a2) > 0 )
{
if ( a3 == 1 )
{
v10 = 0;
while ( 1 )
{
bio_X509_AUX = PEM_read_bio_X509_AUX((__int64)v8, 0, nullptr, nullptr);
if ( !bio_X509_AUX )
break;
++v10;
if ( !(unsigned int)X509_STORE_add_cert(*(_QWORD *)(a1 + 24), bio_X509_AUX) )
{
v10 = 0;
goto LABEL_7;
}
X509_free(bio_X509_AUX);
}
if ( (ERR_peek_last_error() & 0xFFF) == 0x6C && v10 )
{
ERR_clear_error();
}
else
{
v10 = 0;
ERR_put_error(11, 111, 9, (__int64)"crypto/x509/by_file.c", 100);
}
}
else if ( a3 == 2 )
{
bio_X509_AUX = d2i_X509_bio(v8, 0);
if ( bio_X509_AUX )
{
v10 = X509_STORE_add_cert(*(_QWORD *)(a1 + 24), bio_X509_AUX);
}
else
{
v10 = 0;
ERR_put_error(11, 111, 13, (__int64)"crypto/x509/by_file.c", 115);
}
}
else
{
bio_X509_AUX = 0;
v10 = 0;
ERR_put_error(11, 111, 100, (__int64)"crypto/x509/by_file.c", 123);
}
}
else
{
bio_X509_AUX = 0;
ERR_put_error(11, 111, 2, (__int64)"crypto/x509/by_file.c", 87);
v10 = 0;
}
LABEL_7:
X509_free(bio_X509_AUX);
BIO_free(v8);
return v10;
}