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 <cedric.bail@free.fr>
Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Differential Revision: https://phab.enlightenment.org/D12103
This commit is contained in:
João Paulo Taylor Ienczak Zanette 2020-08-10 23:08:42 +00:00 committed by Stefan Schmidt
parent eed4068fa2
commit f6672c91a8
1 changed files with 14 additions and 17 deletions

View File

@ -185,21 +185,19 @@ on_error:
# else /* ifdef HAVE_GNUTLS */ # else /* ifdef HAVE_GNUTLS */
/* Openssl private declarations */ /* Openssl private declarations */
FILE *fp;
EVP_PKEY *pkey = NULL; EVP_PKEY *pkey = NULL;
X509 *cert = NULL; X509 *cert = NULL;
if (!emile_cipher_init()) return NULL; if (!emile_cipher_init()) return NULL;
/* Load the X509 certificate in memory. */ /* Load the X509 certificate in memory. */
fp = fopen(certificate_file, "rb"); {
if (!fp) BIO* cert_bio = BIO_new_file(certificate_file, "rb");
return NULL; cert = PEM_read_bio_X509(cert_bio, NULL, NULL, NULL);
BIO_free(cert_bio);
cert = PEM_read_X509(fp, NULL, NULL, NULL); if (!cert)
fclose(fp); goto on_error;
if (!cert) }
goto on_error;
/* Check the presence of the public key. Just in case. */ /* Check the presence of the public key. Just in case. */
pkey = X509_get_pubkey(cert); pkey = X509_get_pubkey(cert);
@ -207,14 +205,13 @@ on_error:
goto on_error; goto on_error;
/* Load the private key in memory. */ /* Load the private key in memory. */
fp = fopen(private_key_file, "rb"); {
if (!fp) BIO* private_key_bio = BIO_new_file(private_key_file, "rb");
goto on_error; pkey = PEM_read_bio_PrivateKey(private_key_bio, NULL, cb, NULL);
BIO_free(private_key_bio);
pkey = PEM_read_PrivateKey(fp, NULL, cb, NULL); if (!pkey)
fclose(fp); goto on_error;
if (!pkey) }
goto on_error;
/* Load the certificate and the private key in Eet_Key structure */ /* Load the certificate and the private key in Eet_Key structure */
key = malloc(sizeof(Eet_Key)); key = malloc(sizeof(Eet_Key));