p12 = d2i_PKCS12_fp(fp, NULL); This can easily be resolved by using the OpenSSL BIO functions, please check attached patch: PKCS12 *p12 = NULL; [...] BIObio = BIO_new(BIO_s_file()); if (bio) { if (BIO_read_filename(bio, (char)rk->rk_conf.ssl.keystore_location) > 0)...