summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/initconf.c12
-rw-r--r--src/lockdown.c35
-rw-r--r--src/plist.c32
-rw-r--r--src/plist.h1
-rw-r--r--src/userpref.c148
-rw-r--r--src/userpref.h29
6 files changed, 136 insertions, 121 deletions
diff --git a/src/initconf.c b/src/initconf.c
index 7d6aa28..960fb6b 100644
--- a/src/initconf.c
+++ b/src/initconf.c
@@ -93,25 +93,15 @@ int main(int argc, char *argv[]) {
93 gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &root_cert_pem.size); 93 gnutls_x509_crt_export (root_cert, GNUTLS_X509_FMT_PEM, root_cert_pem.data, &root_cert_pem.size);
94 gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &host_cert_pem.size); 94 gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, host_cert_pem.data, &host_cert_pem.size);
95 95
96 /* encode in base64 for storage */
97 char* root_key_b64 = g_base64_encode (root_key_pem.data,root_key_pem.size);
98 char* host_key_b64 = g_base64_encode (host_key_pem.data,host_key_pem.size);
99
100 char* root_cert_b64 = g_base64_encode (root_cert_pem.data,root_cert_pem.size);
101 char* host_cert_b64 = g_base64_encode (host_cert_pem.data,host_cert_pem.size);
102 96
103 /* store values in config file */ 97 /* store values in config file */
104 98
105 init_config_file(host_id, root_key_b64, host_key_b64, root_cert_b64, host_cert_b64); 99 init_config_file(host_id, &root_key_pem, &host_key_pem, &root_cert_pem, &host_cert_pem);
106 100
107 gnutls_free(root_key_pem.data); 101 gnutls_free(root_key_pem.data);
108 gnutls_free(host_key_pem.data); 102 gnutls_free(host_key_pem.data);
109 gnutls_free(root_cert_pem.data); 103 gnutls_free(root_cert_pem.data);
110 gnutls_free(host_cert_pem.data); 104 gnutls_free(host_cert_pem.data);
111 g_free(root_key_b64);
112 g_free(host_key_b64);
113 g_free(root_cert_b64);
114 g_free(host_cert_b64);
115 105
116 return 0; 106 return 0;
117} 107}
diff --git a/src/lockdown.c b/src/lockdown.c
index d5149a9..095b2b4 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -263,8 +263,8 @@ int lockdownd_pair_device(lockdownd_client *control, char *public_key_b64, char
263 263
264 /* Setup Pair request plist */ 264 /* Setup Pair request plist */
265 dict = add_child_to_plist(plist, "dict", "\n", NULL, 0); 265 dict = add_child_to_plist(plist, "dict", "\n", NULL, 0);
266 add_key_str_dict_element(plist, dict, "Key", "PairRecord", 1); 266 dictRecord = add_key_dict_node(plist, dict, "PairRecord", "\n", 1);
267 dictRecord = add_child_to_plist(plist, "dict", "\n", NULL, 1); 267 //dictRecord = add_child_to_plist(plist, "dict", "\n", NULL, 1);
268 add_key_data_dict_element(plist, dictRecord, "DeviceCertificate", device_cert_b64, 2); 268 add_key_data_dict_element(plist, dictRecord, "DeviceCertificate", device_cert_b64, 2);
269 add_key_data_dict_element(plist, dictRecord, "HostCertificate", host_cert_b64, 2); 269 add_key_data_dict_element(plist, dictRecord, "HostCertificate", host_cert_b64, 2);
270 add_key_str_dict_element(plist, dictRecord, "HostID", host_id, 2); 270 add_key_str_dict_element(plist, dictRecord, "HostID", host_id, 2);
@@ -273,6 +273,8 @@ int lockdownd_pair_device(lockdownd_client *control, char *public_key_b64, char
273 273
274 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length); 274 xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
275 275
276 printf("XML Pairing request : %s\n",XML_content);
277
276 /* send to iPhone */ 278 /* send to iPhone */
277 bytes = lockdownd_send(control, XML_content, length); 279 bytes = lockdownd_send(control, XML_content, length);
278 280
@@ -366,34 +368,34 @@ int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char *
366 gnutls_datum_t essentially_null = {strdup("abababababababab"), strlen("abababababababab")}; 368 gnutls_datum_t essentially_null = {strdup("abababababababab"), strlen("abababababababab")};
367 369
368 gnutls_x509_privkey_t fake_privkey, root_privkey; 370 gnutls_x509_privkey_t fake_privkey, root_privkey;
369 gnutls_x509_crt_t dev_cert, root_cert; 371 gnutls_x509_crt_t dev_cert, root_cert, host_cert;
370 372
371 gnutls_x509_privkey_init(&fake_privkey); 373 gnutls_x509_privkey_init(&fake_privkey);
372 gnutls_x509_crt_init(&dev_cert); 374 gnutls_x509_crt_init(&dev_cert);
373 gnutls_x509_crt_init(&root_cert); 375 gnutls_x509_crt_init(&root_cert);
376 gnutls_x509_crt_init(&host_cert);
374 377
375 if ( GNUTLS_E_SUCCESS == gnutls_x509_privkey_import_rsa_raw(fake_privkey, &modulus, &exponent, &essentially_null, &essentially_null, &essentially_null, &essentially_null) ) { 378 if ( GNUTLS_E_SUCCESS == gnutls_x509_privkey_import_rsa_raw(fake_privkey, &modulus, &exponent, &essentially_null, &essentially_null, &essentially_null, &essentially_null) ) {
376 379
377 gnutls_x509_privkey_init(&root_privkey); 380 gnutls_x509_privkey_init(&root_privkey);
378 381
379 /* get certificate stored in config */ 382 /* get root cert */
380 *host_cert_b64 = get_host_certificate();
381 *root_cert_b64 = get_root_certificate();
382
383 gnutls_datum_t pem_root_cert = {NULL, 0}; 383 gnutls_datum_t pem_root_cert = {NULL, 0};
384 pem_root_cert.data = g_base64_decode (*root_cert_b64, &pem_root_cert.size); 384 ret = get_root_certificate(&pem_root_cert);
385
386 ret = gnutls_x509_crt_import (root_cert, &pem_root_cert, GNUTLS_X509_FMT_PEM); 385 ret = gnutls_x509_crt_import (root_cert, &pem_root_cert, GNUTLS_X509_FMT_PEM);
387 gnutls_free(pem_root_cert.data); 386
388 387
388 /* get host cert */
389 gnutls_datum_t pem_host_cert = {NULL, 0};
390 ret = get_host_certificate(&pem_host_cert);
391 ret = gnutls_x509_crt_import (host_cert, &pem_host_cert, GNUTLS_X509_FMT_PEM);
392
389 393
390 /* get root private key */ 394 /* get root private key */
391 char *root_priv_b64 = get_root_private_key();
392 gnutls_datum_t pem_root_priv = {NULL, 0}; 395 gnutls_datum_t pem_root_priv = {NULL, 0};
393 pem_root_priv.data = g_base64_decode (root_priv_b64, &pem_root_priv.size); 396 ret = get_root_private_key(&pem_root_priv);
394
395 ret = gnutls_x509_privkey_import (root_privkey, &pem_root_priv, GNUTLS_X509_FMT_PEM); 397 ret = gnutls_x509_privkey_import (root_privkey, &pem_root_priv, GNUTLS_X509_FMT_PEM);
396 gnutls_free(pem_root_priv.data); 398
397 399
398 /* generate device certificate */ 400 /* generate device certificate */
399 401
@@ -418,8 +420,13 @@ int lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_b64, char *
418 420
419 /* now encode certificates for output */ 421 /* now encode certificates for output */
420 *device_cert_b64 = g_base64_encode(dev_pem.data, dev_pem.size); 422 *device_cert_b64 = g_base64_encode(dev_pem.data, dev_pem.size);
423 *host_cert_b64 = g_base64_encode(pem_host_cert.data, pem_host_cert.size);
424 *root_cert_b64 = g_base64_encode(pem_root_cert.data, pem_root_cert.size);
421 ret = 1; 425 ret = 1;
422 } 426 }
427 gnutls_free(pem_root_priv.data);
428 gnutls_free(pem_root_cert.data);
429 gnutls_free(pem_host_cert.data);
423 } 430 }
424 } 431 }
425 432
diff --git a/src/plist.c b/src/plist.c
index 2d2a832..73cdffc 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -29,6 +29,29 @@ const char *plist_base = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
29<plist version=\"1.0\">\n\ 29<plist version=\"1.0\">\n\
30</plist>\0"; 30</plist>\0";
31 31
32char* format_string(char* buf, int cols, int depth)
33{
34 int colw = depth + cols + 1; //new buf cols width
35 int len = strlen(buf);
36 //int nlines = ceil((float)len / (float)cols);
37 int nlines = len / cols + 1;
38 char* new_buf = (char*)malloc(nlines * colw + depth + 1);
39 int i = 0;
40 int j = 0;
41 for (i = 0; i < nlines; i++){
42 new_buf[i * colw] = '\n';
43 for (j = 0; j < depth; j++)
44 new_buf[i * colw + 1 + j] = '\t';
45 memcpy(new_buf + i * colw + 1 + depth, buf + i * cols, cols);
46 }
47 new_buf[len+(1+depth)*nlines] = '\n';
48 for (j = 0; j < depth; j++)
49 new_buf[len+(1+depth)*nlines + 1 + j] = '\t';
50 new_buf[len+(1+depth)*nlines+depth+1] = '\0';
51 free(buf);
52 return new_buf;
53}
54
32xmlDocPtr new_plist() { 55xmlDocPtr new_plist() {
33 char *plist = strdup(plist_base); 56 char *plist = strdup(plist_base);
34 xmlDocPtr plist_xml = xmlReadMemory(plist, strlen(plist), NULL, NULL, 0); 57 xmlDocPtr plist_xml = xmlReadMemory(plist, strlen(plist), NULL, NULL, 0);
@@ -62,10 +85,17 @@ xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode *dict, const char *ke
62 return keyPtr; 85 return keyPtr;
63} 86}
64 87
88xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) {
89 xmlNode *child;
90 add_child_to_plist(plist, "key", key, dict, depth);
91 child = add_child_to_plist(plist, "dict", value, dict, depth);
92 return child;
93}
94
65xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) { 95xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth) {
66 xmlNode *keyPtr; 96 xmlNode *keyPtr;
67 keyPtr = add_child_to_plist(plist, "key", key, dict, depth); 97 keyPtr = add_child_to_plist(plist, "key", key, dict, depth);
68 add_child_to_plist(plist, "data", value, dict, depth); 98 add_child_to_plist(plist, "data", format_string(value, 60, depth), dict, depth);
69 return keyPtr; 99 return keyPtr;
70} 100}
71 101
diff --git a/src/plist.h b/src/plist.h
index 64ff4d3..a2f558e 100644
--- a/src/plist.h
+++ b/src/plist.h
@@ -25,6 +25,7 @@
25#include <libxml/parser.h> 25#include <libxml/parser.h>
26#include <libxml/tree.h> 26#include <libxml/tree.h>
27 27
28xmlNode *add_key_dict_node(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth);
28xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth); 29xmlNode *add_key_str_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth);
29xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth); 30xmlNode *add_key_data_dict_element(xmlDocPtr plist, xmlNode *dict, const char *key, const char *value, int depth);
30xmlNode *add_child_to_plist(xmlDocPtr plist, const char *name, const char *content, xmlNode *to_node, int depth); 31xmlNode *add_child_to_plist(xmlDocPtr plist, const char *name, const char *content, xmlNode *to_node, int depth);
diff --git a/src/userpref.c b/src/userpref.c
index f93cff4..12ff8f3 100644
--- a/src/userpref.c
+++ b/src/userpref.c
@@ -24,9 +24,16 @@
24#include <string.h> 24#include <string.h>
25#include "userpref.h" 25#include "userpref.h"
26 26
27
27#define LIBIPHONE_CONF_DIR "libiphone" 28#define LIBIPHONE_CONF_DIR "libiphone"
28#define LIBIPHONE_CONF_FILE "libiphonerc" 29#define LIBIPHONE_CONF_FILE "libiphonerc"
29 30
31#define LIBIPHONE_ROOT_PRIVKEY "RootPrivateKey.pem"
32#define LIBIPHONE_HOST_PRIVKEY "HostPrivateKey.pem"
33#define LIBIPHONE_ROOT_CERTIF "RootCertificate.pem"
34#define LIBIPHONE_HOST_CERTIF "HostCertificate.pem"
35
36
30extern int debug; 37extern int debug;
31 38
32inline void create_config_dir() { 39inline void create_config_dir() {
@@ -145,99 +152,59 @@ int store_device_public_key(char* public_key)
145 return 1; 152 return 1;
146} 153}
147 154
148 155int read_file_in_confdir(char* file, gnutls_datum_t* data)
149char* get_root_private_key()
150{ 156{
151 char* private_key = NULL; 157 if (NULL == file || NULL == data)
152 158 return 0;
153 /* first get config file */
154 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
155 if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
156
157 /* now parse file to get knwon devices list */
158 GKeyFile* key_file = g_key_file_new ();
159 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
160 159
161 gchar* loc_private_key = g_key_file_get_value(key_file, "Global", "RootPrivateKey", NULL); 160 gchar* filepath = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, file, NULL);
162 if (loc_private_key) 161 if (g_file_test(filepath, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
163 private_key = strdup((char*)loc_private_key); 162
164 g_free(loc_private_key); 163 FILE * pFile;
165 } 164 long lSize;
166 g_key_file_free(key_file); 165
166 pFile = fopen ( filepath , "rb" );
167 if (pFile==NULL)
168 return 0;
169
170 fseek (pFile , 0 , SEEK_END);
171 data->size = ftell (pFile);
172 rewind (pFile);
173
174 data->data = (char*)gnutls_malloc(data->size);
175 if (data->data == NULL)
176 return 0;
177
178 // copy the file into the buffer:
179 fread (data->data,1,data->size,pFile);
180 fclose (pFile);
167 } 181 }
168 return private_key; 182 return 1;
169} 183}
170 184
171char* get_host_private_key() 185int get_root_private_key(gnutls_datum_t* root_privkey)
172{ 186{
173 char* private_key = NULL; 187 return read_file_in_confdir(LIBIPHONE_ROOT_PRIVKEY, root_privkey);
174
175 /* first get config file */
176 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
177 if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
178
179 /* now parse file to get knwon devices list */
180 GKeyFile* key_file = g_key_file_new ();
181 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
182
183 gchar* loc_private_key = g_key_file_get_value(key_file, "Global", "HostPrivateKey", NULL);
184 if (loc_private_key)
185 private_key = strdup((char*)loc_private_key);
186 g_free(loc_private_key);
187 }
188 g_key_file_free(key_file);
189 }
190 return private_key;
191} 188}
192 189
193 190int get_host_private_key(gnutls_datum_t* host_privkey)
194char* get_root_certificate()
195{ 191{
196 char* cert = NULL; 192 return read_file_in_confdir(LIBIPHONE_HOST_PRIVKEY, host_privkey);
197
198 /* first get config file */
199 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
200 if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
201
202 /* now parse file to get knwon devices list */
203 GKeyFile* key_file = g_key_file_new ();
204 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
205
206 gchar* loc_cert = g_key_file_get_value(key_file, "Global", "RootCertificate", NULL);
207 if (loc_cert)
208 cert = strdup((char*)loc_cert);
209 g_free(loc_cert);
210 }
211 g_key_file_free(key_file);
212 }
213 return cert;
214} 193}
215 194
216char* get_host_certificate() 195int get_root_certificate(gnutls_datum_t* root_cert)
217{ 196{
218 char* cert = NULL; 197 return read_file_in_confdir(LIBIPHONE_ROOT_CERTIF, root_cert);
219 198}
220 /* first get config file */
221 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
222 if (g_file_test(config_file, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
223
224 /* now parse file to get knwon devices list */
225 GKeyFile* key_file = g_key_file_new ();
226 if( g_key_file_load_from_file (key_file, config_file, G_KEY_FILE_KEEP_COMMENTS, NULL) ) {
227 199
228 gchar* loc_cert = g_key_file_get_value(key_file, "Global", "HostCertificate", NULL); 200int get_host_certificate(gnutls_datum_t* host_cert)
229 if (loc_cert) 201{
230 cert = strdup((char*)loc_cert); 202 return read_file_in_confdir(LIBIPHONE_HOST_CERTIF, host_cert);
231 g_free(loc_cert);
232 }
233 g_key_file_free(key_file);
234 }
235 return cert;
236} 203}
237 204
238int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert) 205int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* host_key, gnutls_datum_t* root_cert, gnutls_datum_t* host_cert)
239{ 206{
240 if (!host_id || !root_private_key || !host_private_key || !root_cert || !host_cert) 207 if (!host_id || !root_key || !host_key || !root_cert || !host_cert)
241 return 0; 208 return 0;
242 209
243 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL); 210 gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL);
@@ -249,10 +216,6 @@ int init_config_file(char* host_id, char* root_private_key, char* host_private_k
249 216
250 /* store in config file */ 217 /* store in config file */
251 g_key_file_set_value (key_file, "Global", "HostID", host_id); 218 g_key_file_set_value (key_file, "Global", "HostID", host_id);
252 g_key_file_set_value (key_file, "Global", "RootPrivateKey", root_private_key);
253 g_key_file_set_value (key_file, "Global", "HostPrivateKey", host_private_key);
254 g_key_file_set_value (key_file, "Global", "RootCertificate", root_cert);
255 g_key_file_set_value (key_file, "Global", "HostCertificate", host_cert);
256 219
257 /* write config file on disk */ 220 /* write config file on disk */
258 gsize length; 221 gsize length;
@@ -263,5 +226,28 @@ int init_config_file(char* host_id, char* root_private_key, char* host_private_k
263 226
264 g_key_file_free(key_file); 227 g_key_file_free(key_file);
265 228
229 //now write keys and certifs to disk
230 FILE * pFile;
231 gchar* pem;
232 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_PRIVKEY, NULL);
233 pFile = fopen ( pem , "wb" );
234 fwrite ( root_key->data, 1 , root_key->size , pFile );
235 fclose (pFile);
236
237 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_PRIVKEY, NULL);
238 pFile = fopen ( pem , "wb" );
239 fwrite ( host_key->data, 1 , host_key->size , pFile );
240 fclose (pFile);
241
242 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_ROOT_CERTIF, NULL);
243 pFile = fopen ( pem , "wb" );
244 fwrite ( root_cert->data, 1 , root_cert->size , pFile );
245 fclose (pFile);
246
247 pem = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_HOST_CERTIF, NULL);
248 pFile = fopen ( pem , "wb" );
249 fwrite ( host_cert->data, 1 , host_cert->size , pFile );
250 fclose (pFile);
251
266 return 1; 252 return 1;
267} 253}
diff --git a/src/userpref.h b/src/userpref.h
index cef0bed..441c7be 100644
--- a/src/userpref.h
+++ b/src/userpref.h
@@ -22,6 +22,7 @@
22#ifndef USERPREF_H 22#ifndef USERPREF_H
23#define USERPREF_H 23#define USERPREF_H
24 24
25#include <gnutls/gnutls.h>
25/** 26/**
26* \fn char* get_host_id() 27* \fn char* get_host_id()
27* method to get user's HostID. Caller must free returned buffer. 28* method to get user's HostID. Caller must free returned buffer.
@@ -43,34 +44,34 @@ int is_device_known(char* public_key);
43int store_device_public_key(char* public_key); 44int store_device_public_key(char* public_key);
44 45
45/** 46/**
46* \fn char* get_root_private_key() 47* \fn int get_root_private_key(gnutls_datum_t* root_privkey)
47* \return RootPrivateKey if exists. Returns NULL otherwise. 48* \return 1 if everything went well. Returns 0 otherwise.
48*/ 49*/
49char* get_root_private_key(); 50int get_root_private_key(gnutls_datum_t* root_privkey);
50 51
51/** 52/**
52* \fn char* get_host_private_key() 53* \fn int get_host_private_key(gnutls_datum_t* host_privkey)
53* \return HostPrivateKey if exists. Returns NULL otherwise. 54* \return 1 if everything went well. Returns 0 otherwise.
54*/ 55*/
55char* get_host_private_key(); 56int get_host_private_key(gnutls_datum_t* host_privkey);
56 57
57/** 58/**
58* \fn char* get_root_certificate() 59* \fn int get_root_certificate(gnutls_datum_t* root_cert)
59* \return RootCertificate if exists. Returns NULL otherwise. 60* \return 1 if everything went well. Returns 0 otherwise.
60*/ 61*/
61char* get_root_certificate(); 62int get_root_certificate(gnutls_datum_t* root_cert);
62 63
63/** 64/**
64* \fn char* get_host_certificate() 65* \fn int get_host_certificate(gnutls_datum_t* host_cert)
65* \return HostCertificate if exists. Returns NULL otherwise. 66* \return 1 if everything went well. Returns 0 otherwise.
66*/ 67*/
67char* get_host_certificate(); 68int get_host_certificate(gnutls_datum_t* host_cert);
68 69
69/** 70/**
70* \fn int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert) 71* \fn int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* host_key, gnutls_datum_t* root_cert, gnutls_datum_t* host_cert)
71* setup a brand new config file. 72* setup a brand new config file.
72* \return 1 if everything went well. Returns 0 otherwise. 73* \return 1 if everything went well. Returns 0 otherwise.
73*/ 74*/
74int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert); 75int init_config_file(char* host_id, gnutls_datum_t* root_key, gnutls_datum_t* host_key, gnutls_datum_t* root_cert, gnutls_datum_t* host_cert);
75#endif 76#endif
76 77