summaryrefslogtreecommitdiffstats
path: root/common/userpref.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/userpref.c')
-rw-r--r--common/userpref.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/common/userpref.c b/common/userpref.c
index b985285..a5aa7cb 100644
--- a/common/userpref.c
+++ b/common/userpref.c
@@ -37,10 +37,16 @@
37#include <unistd.h> 37#include <unistd.h>
38#include <usbmuxd.h> 38#include <usbmuxd.h>
39#ifdef HAVE_OPENSSL 39#ifdef HAVE_OPENSSL
40#include <openssl/bn.h>
40#include <openssl/pem.h> 41#include <openssl/pem.h>
41#include <openssl/rsa.h> 42#include <openssl/rsa.h>
42#include <openssl/x509.h> 43#include <openssl/x509.h>
43#include <openssl/x509v3.h> 44#include <openssl/x509v3.h>
45#if OPENSSL_VERSION_NUMBER < 0x1010000fL || \
46 (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x20700000L))
47#define X509_set1_notBefore X509_set_notBefore
48#define X509_set1_notAfter X509_set_notAfter
49#endif
44#else 50#else
45#include <gnutls/gnutls.h> 51#include <gnutls/gnutls.h>
46#include <gnutls/crypto.h> 52#include <gnutls/crypto.h>
@@ -420,9 +426,9 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
420 /* set key validity */ 426 /* set key validity */
421 ASN1_TIME* asn1time = ASN1_TIME_new(); 427 ASN1_TIME* asn1time = ASN1_TIME_new();
422 ASN1_TIME_set(asn1time, time(NULL)); 428 ASN1_TIME_set(asn1time, time(NULL));
423 X509_set_notBefore(root_cert, asn1time); 429 X509_set1_notBefore(root_cert, asn1time);
424 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10)); 430 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10));
425 X509_set_notAfter(root_cert, asn1time); 431 X509_set1_notAfter(root_cert, asn1time);
426 ASN1_TIME_free(asn1time); 432 ASN1_TIME_free(asn1time);
427 433
428 /* use root public key for root cert */ 434 /* use root public key for root cert */
@@ -453,9 +459,9 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
453 /* set key validity */ 459 /* set key validity */
454 ASN1_TIME* asn1time = ASN1_TIME_new(); 460 ASN1_TIME* asn1time = ASN1_TIME_new();
455 ASN1_TIME_set(asn1time, time(NULL)); 461 ASN1_TIME_set(asn1time, time(NULL));
456 X509_set_notBefore(host_cert, asn1time); 462 X509_set1_notBefore(host_cert, asn1time);
457 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10)); 463 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10));
458 X509_set_notAfter(host_cert, asn1time); 464 X509_set1_notAfter(host_cert, asn1time);
459 ASN1_TIME_free(asn1time); 465 ASN1_TIME_free(asn1time);
460 466
461 /* use host public key for host cert */ 467 /* use host public key for host cert */
@@ -533,9 +539,9 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
533 539
534 ASN1_TIME* asn1time = ASN1_TIME_new(); 540 ASN1_TIME* asn1time = ASN1_TIME_new();
535 ASN1_TIME_set(asn1time, time(NULL)); 541 ASN1_TIME_set(asn1time, time(NULL));
536 X509_set_notBefore(dev_cert, asn1time); 542 X509_set1_notBefore(dev_cert, asn1time);
537 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10)); 543 ASN1_TIME_set(asn1time, time(NULL) + (60 * 60 * 24 * 365 * 10));
538 X509_set_notAfter(dev_cert, asn1time); 544 X509_set1_notAfter(dev_cert, asn1time);
539 ASN1_TIME_free(asn1time); 545 ASN1_TIME_free(asn1time);
540 546
541 EVP_PKEY* pkey = EVP_PKEY_new(); 547 EVP_PKEY* pkey = EVP_PKEY_new();