forked from enlightenment/efl
parent
32dbc61034
commit
e678664d12
|
@ -92,7 +92,6 @@ eet_identity_open(const char *certificate_file, const char *private_key_file, Ee
|
||||||
struct stat st;
|
struct stat st;
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
gnutls_datum_t load_file = { NULL, 0 };
|
gnutls_datum_t load_file = { NULL, 0 };
|
||||||
int res;
|
|
||||||
char pass[1024];
|
char pass[1024];
|
||||||
|
|
||||||
/* Init */
|
/* Init */
|
||||||
|
@ -109,7 +108,7 @@ eet_identity_open(const char *certificate_file, const char *private_key_file, Ee
|
||||||
/* Import the certificate in Eet_Key structure */
|
/* Import the certificate in Eet_Key structure */
|
||||||
load_file.data = data;
|
load_file.data = data;
|
||||||
load_file.size = st.st_size;
|
load_file.size = st.st_size;
|
||||||
if ((res = gnutls_x509_crt_import(key->certificate, &load_file, GNUTLS_X509_FMT_PEM)) < 0)
|
if (gnutls_x509_crt_import(key->certificate, &load_file, GNUTLS_X509_FMT_PEM) < 0)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
if (munmap(data, st.st_size)) goto on_error;
|
if (munmap(data, st.st_size)) goto on_error;
|
||||||
|
|
||||||
|
@ -130,19 +129,19 @@ eet_identity_open(const char *certificate_file, const char *private_key_file, Ee
|
||||||
load_file.data = data;
|
load_file.data = data;
|
||||||
load_file.size = st.st_size;
|
load_file.size = st.st_size;
|
||||||
/* Try to directly import the PEM encoded private key */
|
/* Try to directly import the PEM encoded private key */
|
||||||
if ((res = gnutls_x509_privkey_import(key->private_key, &load_file, GNUTLS_X509_FMT_PEM)) < 0)
|
if (gnutls_x509_privkey_import(key->private_key, &load_file, GNUTLS_X509_FMT_PEM) < 0)
|
||||||
{
|
{
|
||||||
/* Else ask for the private key pass */
|
/* Else ask for the private key pass */
|
||||||
if (cb && cb(pass, 1024, 0, NULL))
|
if (cb && cb(pass, 1024, 0, NULL))
|
||||||
{
|
{
|
||||||
/* If pass then try to decode the pkcs 8 private key */
|
/* If pass then try to decode the pkcs 8 private key */
|
||||||
if ((res = gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file, GNUTLS_X509_FMT_PEM, pass, 0)))
|
if (gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file, GNUTLS_X509_FMT_PEM, pass, 0))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Else try to import the pkcs 8 private key without pass */
|
/* Else try to import the pkcs 8 private key without pass */
|
||||||
if ((res = gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file, GNUTLS_X509_FMT_PEM, NULL, 1)))
|
if (gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file, GNUTLS_X509_FMT_PEM, NULL, 1))
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue