From f6672c91a8fb65e04dc5bb6bbb37fb6d72b11715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Taylor=20Ienczak=20Zanette?= Date: Mon, 10 Aug 2020 23:08:42 +0000 Subject: [PATCH] eet: Fix 'No OPENSSL_Applink' error message. In some systems (such as Windows), OpenSSL raises an error about "No Applink" (see ["I've compiled a program under Windows and it crashes: why?" in OpenSSL FAQ](https://www.openssl.org/docs/faq.html#PROG3)). Including only openssl/applink.c didn't work, so the solution was to replace `FILE*` interfaces with OpenSSL's BIO API which also contains file operations. Reviewed-by: Cedric BAIL Reviewed-by: Stefan Schmidt Differential Revision: https://phab.enlightenment.org/D12103 --- src/lib/eet/eet_cipher.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/lib/eet/eet_cipher.c b/src/lib/eet/eet_cipher.c index 2314c24e03..51f8513dce 100644 --- a/src/lib/eet/eet_cipher.c +++ b/src/lib/eet/eet_cipher.c @@ -185,21 +185,19 @@ on_error: # else /* ifdef HAVE_GNUTLS */ /* Openssl private declarations */ - FILE *fp; EVP_PKEY *pkey = NULL; X509 *cert = NULL; if (!emile_cipher_init()) return NULL; /* Load the X509 certificate in memory. */ - fp = fopen(certificate_file, "rb"); - if (!fp) - return NULL; - - cert = PEM_read_X509(fp, NULL, NULL, NULL); - fclose(fp); - if (!cert) - goto on_error; + { + BIO* cert_bio = BIO_new_file(certificate_file, "rb"); + cert = PEM_read_bio_X509(cert_bio, NULL, NULL, NULL); + BIO_free(cert_bio); + if (!cert) + goto on_error; + } /* Check the presence of the public key. Just in case. */ pkey = X509_get_pubkey(cert); @@ -207,14 +205,13 @@ on_error: goto on_error; /* Load the private key in memory. */ - fp = fopen(private_key_file, "rb"); - if (!fp) - goto on_error; - - pkey = PEM_read_PrivateKey(fp, NULL, cb, NULL); - fclose(fp); - if (!pkey) - goto on_error; + { + BIO* private_key_bio = BIO_new_file(private_key_file, "rb"); + pkey = PEM_read_bio_PrivateKey(private_key_bio, NULL, cb, NULL); + BIO_free(private_key_bio); + if (!pkey) + goto on_error; + } /* Load the certificate and the private key in Eet_Key structure */ key = malloc(sizeof(Eet_Key));