OpenSSL Cryptography – code in C++ for Signature Verification

I am trying to verify a signature using OpenSSL in C++. The code is below:

bool verifySignature(QString updateInfo_file_signature, QString uInfo_file_hash) {
    RSA *rsa = NULL;
    BIO *keybio;

    FILE *file = fopen("pubkey.pem", "rb");
    fseek(file, 0, SEEK_END);
    long fsize = ftell(file);
    fseek(file, 0, SEEK_SET);

    char *key = (char*)malloc(fsize + 1);
    fread(key, 1, fsize, file);
    fclose(file);

    keybio = BIO_new_mem_buf((void*)key, -1);
    if (keybio==NULL)
        return 0;

    rsa = PEM_read_bio_RSA_PUBKEY(keybio, &rsa,NULL, NULL);
    if(rsa == NULL)
        return 0;
    
    int rsa_size = RSA_size(rsa);

    // vars
    const char* sign_file_hash = uInfo_file_hash.toStdString().c_str();
    unsigned char* u_file_hash = (unsigned char*) uInfo_file_hash.toLocal8Bit().data();

    const char* sign_file_sig = updateInfo_file_signature.toStdString().c_str();
    unsigned char* u_file_sig = (unsigned char*) updateInfo_file_signature.toLocal8Bit().data();

    int hash_size = strlen(sign_file_hash);
    int sig_size = strlen(sign_file_sig);

    int res = RSA_verify(NID_sha1, u_file_hash, 16, u_file_sig, rsa_size, rsa);
    printError();

    return 0;
}

But I am getting this error:

error:0407008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding

Here is my public key:

-----BEGIN PUBLIC KEY-----
LjkdiljJKCgkqhkiG9w0BwKHSFLDFMJVDKlkfdjLJSDISDFMKIJ3l4jitiofudJC
lksj3XAcPVWaLJDIOFVMKji495glkfmsfdiou8lfmdfl7suHeDrWx1XRoLWeKbpt
0MHiXInH3BMV9iRH83RX3FPhrenFND4OZenqqfXuh2n0zZrdyZGqlum73wx6YoRs
/BG8/Xq4ycVOeMSBKc+KcKMofWNpLZRmnzarS9reTv0bKr7/WFUHKOkeiou8or3m
KJDFMK8m
-----END PUBLIC KEY-----

Here is file Signature (updateInfo_file_signature::QString): saKBgdDIS/rsb7Uazr6zWMYsGLU8CYN6YaUZh5nyNjo7PCImCNtXBV+4TuFnKV6obz1rdqqUX+0Lwan8gquqQzYlsdfjkISFG4R9lkjdfilO8U4RNFU35Gbko/iSGlkg8F/DVCSPsSttlhhQJjjHCbMB9i+DgzFMCDYVhd9lrtuEVDauXDtEbyA1G3i5LT9H6Hr7XUTQN7QAnbHxCdtPc81FHO9+WEdu/lDdmT+rfWKO1REEeOVd/0Pf/pGTCVdnVsCA+S3UD310Ft13UB8KyQ5xN/KrncUFibaKzzKlihsdKHSDFKlkerLJSLJMV7rfJq9KDw==

Here is computed File hash in sha256 (uInfo_file_hash::QString):
712b6ec279d490ede7454f34d1f6ffff

I have tried cat -v pubkey.pem but still it seems legit.

I’ve been struggling with it for days, please review my code and help me out.