summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>2020-08-10 23:08:42 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-08-19 15:59:52 +0200
commitf6672c91a8fb65e04dc5bb6bbb37fb6d72b11715 (patch)
treebd74af3f1581e29e2c7b9a99e1629dca8a8bd67d
parenteed4068fa2a24693514a7713b779b7a84e803b85 (diff)
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
-rw-r--r--src/lib/eet/eet_cipher.c31
1 files 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:
185 185
186# else /* ifdef HAVE_GNUTLS */ 186# else /* ifdef HAVE_GNUTLS */
187 /* Openssl private declarations */ 187 /* Openssl private declarations */
188 FILE *fp;
189 EVP_PKEY *pkey = NULL; 188 EVP_PKEY *pkey = NULL;
190 X509 *cert = NULL; 189 X509 *cert = NULL;
191 190
192 if (!emile_cipher_init()) return NULL; 191 if (!emile_cipher_init()) return NULL;
193 192
194 /* Load the X509 certificate in memory. */ 193 /* Load the X509 certificate in memory. */
195 fp = fopen(certificate_file, "rb"); 194 {
196 if (!fp) 195 BIO* cert_bio = BIO_new_file(certificate_file, "rb");
197 return NULL; 196 cert = PEM_read_bio_X509(cert_bio, NULL, NULL, NULL);
198 197 BIO_free(cert_bio);
199 cert = PEM_read_X509(fp, NULL, NULL, NULL); 198 if (!cert)
200 fclose(fp); 199 goto on_error;
201 if (!cert) 200 }
202 goto on_error;
203 201
204 /* Check the presence of the public key. Just in case. */ 202 /* Check the presence of the public key. Just in case. */
205 pkey = X509_get_pubkey(cert); 203 pkey = X509_get_pubkey(cert);
@@ -207,14 +205,13 @@ on_error:
207 goto on_error; 205 goto on_error;
208 206
209 /* Load the private key in memory. */ 207 /* Load the private key in memory. */
210 fp = fopen(private_key_file, "rb"); 208 {
211 if (!fp) 209 BIO* private_key_bio = BIO_new_file(private_key_file, "rb");
212 goto on_error; 210 pkey = PEM_read_bio_PrivateKey(private_key_bio, NULL, cb, NULL);
213 211 BIO_free(private_key_bio);
214 pkey = PEM_read_PrivateKey(fp, NULL, cb, NULL); 212 if (!pkey)
215 fclose(fp); 213 goto on_error;
216 if (!pkey) 214 }
217 goto on_error;
218 215
219 /* Load the certificate and the private key in Eet_Key structure */ 216 /* Load the certificate and the private key in Eet_Key structure */
220 key = malloc(sizeof(Eet_Key)); 217 key = malloc(sizeof(Eet_Key));