diff options
| -rw-r--r-- | src/initconf.c | 13 | ||||
| -rw-r--r-- | src/userpref.c | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/initconf.c b/src/initconf.c index de583fa..7d6aa28 100644 --- a/src/initconf.c +++ b/src/initconf.c | |||
| @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { | |||
| 29 | 29 | ||
| 30 | gnutls_global_init(); | 30 | gnutls_global_init(); |
| 31 | 31 | ||
| 32 | char* host_id = NULL; | 32 | char* host_id = "29942970-207913891623273984"; |
| 33 | gnutls_x509_privkey_t root_privkey; | 33 | gnutls_x509_privkey_t root_privkey; |
| 34 | gnutls_x509_privkey_t host_privkey; | 34 | gnutls_x509_privkey_t host_privkey; |
| 35 | 35 | ||
| @@ -42,9 +42,12 @@ int main(int argc, char *argv[]) { | |||
| 42 | gnutls_x509_crt_init(&root_cert); | 42 | gnutls_x509_crt_init(&root_cert); |
| 43 | gnutls_x509_crt_init(&host_cert); | 43 | gnutls_x509_crt_init(&host_cert); |
| 44 | 44 | ||
| 45 | /* generate HostID */ | ||
| 46 | //TODO | ||
| 47 | |||
| 45 | /* generate keys */ | 48 | /* generate keys */ |
| 46 | int ret1 = gnutls_x509_privkey_generate(root_privkey, GNUTLS_PK_RSA, 2048, 0); | 49 | gnutls_x509_privkey_generate(root_privkey, GNUTLS_PK_RSA, 2048, 0); |
| 47 | int ret2 = gnutls_x509_privkey_generate(host_privkey, GNUTLS_PK_RSA, 2048, 0); | 50 | gnutls_x509_privkey_generate(host_privkey, GNUTLS_PK_RSA, 2048, 0); |
| 48 | 51 | ||
| 49 | /* generate certificates */ | 52 | /* generate certificates */ |
| 50 | gnutls_x509_crt_set_key(root_cert, root_privkey); | 53 | gnutls_x509_crt_set_key(root_cert, root_privkey); |
| @@ -73,7 +76,7 @@ int main(int argc, char *argv[]) { | |||
| 73 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_pem.size); | 76 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, NULL, &host_key_pem.size); |
| 74 | 77 | ||
| 75 | root_key_pem.data = gnutls_malloc(root_key_pem.size); | 78 | root_key_pem.data = gnutls_malloc(root_key_pem.size); |
| 76 | root_key_pem.data = gnutls_malloc(root_key_pem.size); | 79 | host_key_pem.data = gnutls_malloc(host_key_pem.size); |
| 77 | 80 | ||
| 78 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &root_key_pem.size); | 81 | gnutls_x509_privkey_export (root_privkey, GNUTLS_X509_FMT_PEM, root_key_pem.data, &root_key_pem.size); |
| 79 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &host_key_pem.size); | 82 | gnutls_x509_privkey_export (host_privkey, GNUTLS_X509_FMT_PEM, host_key_pem.data, &host_key_pem.size); |
| @@ -85,7 +88,7 @@ int main(int argc, char *argv[]) { | |||
| 85 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_pem.size); | 88 | gnutls_x509_crt_export (host_cert, GNUTLS_X509_FMT_PEM, NULL, &host_cert_pem.size); |
| 86 | 89 | ||
| 87 | root_cert_pem.data = gnutls_malloc(root_cert_pem.size); | 90 | root_cert_pem.data = gnutls_malloc(root_cert_pem.size); |
| 88 | root_cert_pem.data = gnutls_malloc(root_cert_pem.size); | 91 | host_cert_pem.data = gnutls_malloc(host_cert_pem.size); |
| 89 | 92 | ||
| 90 | 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); |
| 91 | 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); |
diff --git a/src/userpref.c b/src/userpref.c index 399e054..f93cff4 100644 --- a/src/userpref.c +++ b/src/userpref.c | |||
| @@ -237,7 +237,7 @@ char* get_host_certificate() | |||
| 237 | 237 | ||
| 238 | int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert) | 238 | int init_config_file(char* host_id, char* root_private_key, char* host_private_key, char* root_cert, char* host_cert) |
| 239 | { | 239 | { |
| 240 | if (!host_id || !root_private_key || !host_private_key) | 240 | if (!host_id || !root_private_key || !host_private_key || !root_cert || !host_cert) |
| 241 | return 0; | 241 | return 0; |
| 242 | 242 | ||
| 243 | gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL); | 243 | gchar* config_file = g_build_path(G_DIR_SEPARATOR_S, g_get_user_config_dir(), LIBIPHONE_CONF_DIR, LIBIPHONE_CONF_FILE, NULL); |
