diff options
| author | 2013-09-06 05:52:49 +0200 | |
|---|---|---|
| committer | 2013-09-17 11:43:34 +0200 | |
| commit | e2f5717487f6950ff6253ccce6a967b0ad9ebbea (patch) | |
| tree | c62b8477bcb0d20a7b8ac4f4285686bcd31a5484 /common/userpref.c | |
| parent | f89e375e1334996591322cf6a454f9e121e423d2 (diff) | |
| download | libimobiledevice-e2f5717487f6950ff6253ccce6a967b0ad9ebbea.tar.gz libimobiledevice-e2f5717487f6950ff6253ccce6a967b0ad9ebbea.tar.bz2 | |
Make sure to re-use the DeviceCertificate instead of generating a new one every time
This prevented iTunes from using a pairing made by libimobiledevice giving an error
that the device sent invalid data.
Diffstat (limited to 'common/userpref.c')
| -rw-r--r-- | common/userpref.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/common/userpref.c b/common/userpref.c index 571b660..55ab9c4 100644 --- a/common/userpref.c +++ b/common/userpref.c | |||
| @@ -1115,7 +1115,7 @@ userpref_error_t userpref_device_record_get_keys_and_certs(const char *udid, gnu | |||
| 1115 | * | 1115 | * |
| 1116 | * @return 1 if the certificates were successfully retrieved, 0 otherwise | 1116 | * @return 1 if the certificates were successfully retrieved, 0 otherwise |
| 1117 | */ | 1117 | */ |
| 1118 | userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_data_t *pem_root_cert, key_data_t *pem_host_cert) | 1118 | userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_data_t *pem_root_cert, key_data_t *pem_host_cert, key_data_t *pem_device_cert) |
| 1119 | { | 1119 | { |
| 1120 | if (!udid || !pem_root_cert || !pem_host_cert) | 1120 | if (!udid || !pem_root_cert || !pem_host_cert) |
| 1121 | return USERPREF_E_INVALID_ARG; | 1121 | return USERPREF_E_INVALID_ARG; |
| @@ -1124,6 +1124,7 @@ userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_d | |||
| 1124 | uint64_t length = 0; | 1124 | uint64_t length = 0; |
| 1125 | plist_t root_cert = NULL; | 1125 | plist_t root_cert = NULL; |
| 1126 | plist_t host_cert = NULL; | 1126 | plist_t host_cert = NULL; |
| 1127 | plist_t dev_cert = NULL; | ||
| 1127 | if (userpref_device_record_get_value(udid, USERPREF_HOST_CERTIFICATE_KEY, &host_cert) && | 1128 | if (userpref_device_record_get_value(udid, USERPREF_HOST_CERTIFICATE_KEY, &host_cert) && |
| 1128 | userpref_device_record_get_value(udid, USERPREF_ROOT_CERTIFICATE_KEY, &root_cert)) { | 1129 | userpref_device_record_get_value(udid, USERPREF_ROOT_CERTIFICATE_KEY, &root_cert)) { |
| 1129 | if (host_cert && plist_get_node_type(host_cert) == PLIST_DATA) { | 1130 | if (host_cert && plist_get_node_type(host_cert) == PLIST_DATA) { |
| @@ -1143,6 +1144,18 @@ userpref_error_t userpref_device_record_get_certs_as_pem(const char *udid, key_d | |||
| 1143 | buffer = NULL; | 1144 | buffer = NULL; |
| 1144 | } | 1145 | } |
| 1145 | 1146 | ||
| 1147 | if (pem_device_cert) { | ||
| 1148 | userpref_device_record_get_value(udid, USERPREF_DEVICE_CERTIFICATE_KEY, &dev_cert); | ||
| 1149 | if (dev_cert && plist_get_node_type(dev_cert) == PLIST_DATA) { | ||
| 1150 | plist_get_data_val(dev_cert, &buffer, &length); | ||
| 1151 | pem_device_cert->data = (unsigned char*)malloc(length); | ||
| 1152 | memcpy(pem_device_cert->data, buffer, length); | ||
| 1153 | pem_device_cert->size = length; | ||
| 1154 | free(buffer); | ||
| 1155 | buffer = NULL; | ||
| 1156 | } | ||
| 1157 | } | ||
| 1158 | |||
| 1146 | return USERPREF_E_SUCCESS; | 1159 | return USERPREF_E_SUCCESS; |
| 1147 | } else { | 1160 | } else { |
| 1148 | if (pem_root_cert->data) { | 1161 | if (pem_root_cert->data) { |
