summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-03-21 18:39:14 +0100
committerGravatar Nikias Bassen2014-03-21 18:39:14 +0100
commita719dd9f3213a9f39ea5e6784595b351e2fcaa3a (patch)
tree9ee013af4cb11d6873eb6c1797bcca8739b31f6b /common
parent03ad1dc56830bd6e921e58ecce2b8b0fd3aea675 (diff)
downloadlibimobiledevice-a719dd9f3213a9f39ea5e6784595b351e2fcaa3a.tar.gz
libimobiledevice-a719dd9f3213a9f39ea5e6784595b351e2fcaa3a.tar.bz2
userpref: fix GnuTLS key generation
Diffstat (limited to 'common')
-rw-r--r--common/userpref.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/common/userpref.c b/common/userpref.c
index cb74945..04341a4 100644
--- a/common/userpref.c
+++ b/common/userpref.c
@@ -609,7 +609,6 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
gnutls_x509_privkey_t host_privkey;
gnutls_x509_crt_t host_cert;
- gnutls_global_deinit();
gnutls_global_init();
/* use less secure random to speed up key generation */
@@ -744,11 +743,10 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
if (USERPREF_E_SUCCESS == ret) {
/* if everything went well, export in PEM format */
size_t export_size = 0;
- gnutls_datum_t dev_pem = { NULL, 0 };
gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, NULL, &export_size);
- dev_pem.data = gnutls_malloc(export_size);
- gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_pem.data, &export_size);
- dev_pem.size = export_size;
+ dev_cert_pem.data = gnutls_malloc(export_size);
+ gnutls_x509_crt_export(dev_cert, GNUTLS_X509_FMT_PEM, dev_cert_pem.data, &export_size);
+ dev_cert_pem.size = export_size;
}
}
@@ -769,9 +767,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
gnutls_free(der_pub_key.data);
- /* restore gnutls env */
gnutls_global_deinit();
- gnutls_global_init();
#endif
if (NULL != root_cert_pem.data && 0 != root_cert_pem.size &&
NULL != host_cert_pem.data && 0 != host_cert_pem.size)