diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-07-30 13:40:40 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-07-30 13:40:40 +0000 |
commit | 90aa70b2a5cfacf36b77dcadf0755a4a9ee90d5e (patch) | |
tree | 7d1060e1771dc8df1500820729038e9e74b8ec5b /src | |
parent | 748cbd5009e7882d74f4e45467885ec9dde55cac (diff) | |
download | gnunet-90aa70b2a5cfacf36b77dcadf0755a4a9ee90d5e.tar.gz gnunet-90aa70b2a5cfacf36b77dcadf0755a4a9ee90d5e.zip |
Removing private key file and certificate before and after every run to
test key and cert generation
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_https.c | 6 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_https.c | 72 |
2 files changed, 73 insertions, 5 deletions
diff --git a/src/transport/plugin_transport_https.c b/src/transport/plugin_transport_https.c index 11a9c9fe8..b7a9465b8 100644 --- a/src/transport/plugin_transport_https.c +++ b/src/transport/plugin_transport_https.c | |||
@@ -43,9 +43,9 @@ | |||
43 | 43 | ||
44 | #define DEBUG_HTTPS GNUNET_YES | 44 | #define DEBUG_HTTPS GNUNET_YES |
45 | #define VERBOSE GNUNET_YES | 45 | #define VERBOSE GNUNET_YES |
46 | #define DEBUG_CURL GNUNET_YES | 46 | #define DEBUG_CURL GNUNET_NO |
47 | #define DEBUG_CONNECTIONS GNUNET_YES | 47 | #define DEBUG_CONNECTIONS GNUNET_NO |
48 | #define DEBUG_SESSION_SELECTION GNUNET_YES | 48 | #define DEBUG_SESSION_SELECTION GNUNET_NO |
49 | 49 | ||
50 | #define INBOUND GNUNET_NO | 50 | #define INBOUND GNUNET_NO |
51 | #define OUTBOUND GNUNET_YES | 51 | #define OUTBOUND GNUNET_YES |
diff --git a/src/transport/test_plugin_transport_https.c b/src/transport/test_plugin_transport_https.c index e2102a2f9..e5c661ae9 100644 --- a/src/transport/test_plugin_transport_https.c +++ b/src/transport/test_plugin_transport_https.c | |||
@@ -384,6 +384,10 @@ static CURLM *multi_handle; | |||
384 | */ | 384 | */ |
385 | static GNUNET_SCHEDULER_TaskIdentifier http_task_send; | 385 | static GNUNET_SCHEDULER_TaskIdentifier http_task_send; |
386 | 386 | ||
387 | |||
388 | static char * key_file; | ||
389 | static char * cert_file; | ||
390 | |||
387 | /** | 391 | /** |
388 | * Shutdown testcase | 392 | * Shutdown testcase |
389 | */ | 393 | */ |
@@ -462,6 +466,27 @@ shutdown_clean () | |||
462 | GNUNET_SCHEDULER_shutdown(sched); | 466 | GNUNET_SCHEDULER_shutdown(sched); |
463 | GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); | 467 | GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http"); |
464 | 468 | ||
469 | struct stat sbuf; | ||
470 | |||
471 | if (0 == stat (cert_file, &sbuf )) | ||
472 | { | ||
473 | if (0 == remove(cert_file)) | ||
474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file); | ||
475 | else | ||
476 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file); | ||
477 | } | ||
478 | |||
479 | if (0 == stat (key_file, &sbuf )) | ||
480 | { | ||
481 | if (0 == remove(key_file)) | ||
482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file); | ||
483 | else | ||
484 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file); | ||
485 | } | ||
486 | |||
487 | GNUNET_free (key_file); | ||
488 | GNUNET_free (cert_file); | ||
489 | |||
465 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); | 490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n"); |
466 | exit(fail); | 491 | exit(fail); |
467 | return; | 492 | return; |
@@ -1135,8 +1160,7 @@ run (void *cls, | |||
1135 | unsigned long long tneigh; | 1160 | unsigned long long tneigh; |
1136 | struct Plugin_Address * cur; | 1161 | struct Plugin_Address * cur; |
1137 | const char * addr_str; | 1162 | const char * addr_str; |
1138 | 1163 | struct stat sbuf; | |
1139 | |||
1140 | unsigned int suggest_res; | 1164 | unsigned int suggest_res; |
1141 | 1165 | ||
1142 | fail_pretty_printer = GNUNET_YES; | 1166 | fail_pretty_printer = GNUNET_YES; |
@@ -1185,6 +1209,50 @@ run (void *cls, | |||
1185 | "transport-http"); | 1209 | "transport-http"); |
1186 | } | 1210 | } |
1187 | 1211 | ||
1212 | /* Get private key file from config */ | ||
1213 | if (GNUNET_CONFIGURATION_have_value (cfg, | ||
1214 | "transport-https", "KEY_FILE")) | ||
1215 | { | ||
1216 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
1217 | "transport-https", | ||
1218 | "KEY_FILE", | ||
1219 | &key_file); | ||
1220 | } | ||
1221 | else | ||
1222 | { | ||
1223 | GNUNET_asprintf(&key_file,"https.key"); | ||
1224 | } | ||
1225 | |||
1226 | if (0 == stat (key_file, &sbuf )) | ||
1227 | { | ||
1228 | if (0 == remove(key_file)) | ||
1229 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file); | ||
1230 | else | ||
1231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file); | ||
1232 | } | ||
1233 | |||
1234 | /* Get private key file from config */ | ||
1235 | if (GNUNET_CONFIGURATION_have_value (cfg, | ||
1236 | "transport-https", "CERT_FILE")) | ||
1237 | { | ||
1238 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
1239 | "transport-https", | ||
1240 | "CERT_FILE", | ||
1241 | &cert_file); | ||
1242 | } | ||
1243 | else | ||
1244 | { | ||
1245 | GNUNET_asprintf(&cert_file,"https.cert"); | ||
1246 | } | ||
1247 | |||
1248 | if (0 == stat (cert_file, &sbuf )) | ||
1249 | { | ||
1250 | if (0 == remove(cert_file)) | ||
1251 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file); | ||
1252 | else | ||
1253 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file); | ||
1254 | } | ||
1255 | |||
1188 | max_connect_per_transport = (uint32_t) tneigh; | 1256 | max_connect_per_transport = (uint32_t) tneigh; |
1189 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 1257 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
1190 | GNUNET_free (keyfile); | 1258 | GNUNET_free (keyfile); |