//
// SSL_use_certificate_chain_file from 0x79cc98 to 0x79ce54 (444 bytes)
//
// 2 xrefs:
// > sub_7BB4F4 @ 0x7bb52c
// > ??> @ 0x5c99c
//
// 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
//
int __fastcall SSL_use_certificate_chain_file(int a1, int a2)
{
int v4; // r0
int v5; // r7
int v6; // r8
int v7; // r0
int v8; // r0
int v9; // r6
int bio_X509_AUX; // r0
int v11; // r11
int v12; // r9
int v13; // r0
_DWORD *bio_X509; // r5
unsigned int error; // r0
v4 = ERR_clear_error(a1);
v5 = *(_DWORD *)(a1 + 2848);
v6 = *(_DWORD *)(a1 + 2852);
v7 = BIO_s_file(v4);
v8 = BIO_new(v7);
v9 = v8;
if ( v8 )
{
if ( BIO_ctrl(v8, 108, 3, a2) <= 0 )
{
v11 = 0;
ERR_put_error(20, 220, 2, "ssl/ssl_rsa.c", 611);
v12 = 0;
}
else
{
bio_X509_AUX = PEM_read_bio_X509_AUX(v9, 0, v5, v6);
v11 = bio_X509_AUX;
if ( bio_X509_AUX )
{
v12 = SSL_use_certificate(a1, bio_X509_AUX);
v13 = ERR_peek_error() == 0;
if ( !v12 )
v13 = 0;
if ( v13 && (v13 = SSL_ctrl(a1, 88, 0, nullptr)) != 0 )
{
while ( 1 )
{
bio_X509 = (_DWORD *)PEM_read_bio_X509(v9, 0, v5, v6);
if ( !bio_X509 )
break;
if ( !SSL_ctrl(a1, 89, 0, bio_X509) )
{
X509_free(bio_X509);
v12 = 0;
goto LABEL_9;
}
}
error = ERR_peek_last_error(a1, 89, 0, 0);
if ( HIBYTE(error) == 9 && error << 20 == 113246208 )
ERR_clear_error(113246208);
else
v12 = (int)bio_X509;
}
else
{
v12 = v13;
}
}
else
{
ERR_put_error(20, 220, 9, "ssl/ssl_rsa.c", 618);
v12 = 0;
}
}
}
else
{
ERR_put_error(20, 220, 7, "ssl/ssl_rsa.c", 606);
v11 = 0;
v12 = 0;
}
LABEL_9:
X509_free(v11);
BIO_free(v9);
return v12;
}