aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/load_tester/load_tester_creds.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-10-01 14:01:13 +0200
committerMartin Willi <martin@revosec.ch>2012-10-16 13:43:53 +0200
commit24eb73b4fa662f6ce049a4e1276ee183892906d7 (patch)
treeb00153c32f1e7fe036166ee0077050573bb3a55e /src/libcharon/plugins/load_tester/load_tester_creds.c
parent8e2d3075aa181c92c3d2c02aef2f6ac348321e50 (diff)
downloadstrongswan-24eb73b4fa662f6ce049a4e1276ee183892906d7.tar.bz2
strongswan-24eb73b4fa662f6ce049a4e1276ee183892906d7.tar.xz
Added load-tester options to read issuing CA certificate and key from files
Diffstat (limited to 'src/libcharon/plugins/load_tester/load_tester_creds.c')
-rw-r--r--src/libcharon/plugins/load_tester/load_tester_creds.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/libcharon/plugins/load_tester/load_tester_creds.c b/src/libcharon/plugins/load_tester/load_tester_creds.c
index 6d3b6933d..190711cbc 100644
--- a/src/libcharon/plugins/load_tester/load_tester_creds.c
+++ b/src/libcharon/plugins/load_tester/load_tester_creds.c
@@ -182,6 +182,48 @@ static char *default_psk = "default-psk";
*/
static char *default_pwd = "default-pwd";
+
+/**
+ * Load the private key, hard-coded or from a file
+ */
+static private_key_t *load_issuer_key(private_load_tester_creds_t *this)
+{
+ char *path;
+
+ path = lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.issuer_key", NULL, charon->name);
+ if (!path)
+ {
+ return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
+ BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)),
+ BUILD_END);
+ }
+ DBG1(DBG_CFG, "loading load-tester private key from '%s'", path);
+ return lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
+ BUILD_FROM_FILE, path, BUILD_END);
+}
+
+/**
+ * Load the issuing certificate, hard-coded or from a file
+ */
+static certificate_t *load_issuer_cert(private_load_tester_creds_t *this)
+{
+ char *path;
+
+ path = lib->settings->get_str(lib->settings,
+ "%s.plugins.load-tester.issuer_cert", NULL, charon->name);
+ if (!path)
+ {
+ return lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
+ BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)),
+ BUILD_X509_FLAG, X509_CA,
+ BUILD_END);
+ }
+ DBG1(DBG_CFG, "loading load-tester issuer cert from '%s'", path);
+ return lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
+ BUILD_FROM_FILE, path, BUILD_END);
+}
+
METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
private_load_tester_creds_t *this, key_type_t type, identification_t *id)
{
@@ -336,18 +378,14 @@ load_tester_creds_t *load_tester_creds_create()
},
.destroy = _destroy,
},
- .private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
- BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)),
- BUILD_END),
- .ca = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
- BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)),
- BUILD_X509_FLAG, X509_CA,
- BUILD_END),
+ .private = load_issuer_key(this),
+ .ca = load_issuer_cert(this),
.psk = shared_key_create(SHARED_IKE,
chunk_clone(chunk_create(psk, strlen(psk)))),
.pwd = shared_key_create(SHARED_EAP,
chunk_clone(chunk_create(pwd, strlen(pwd)))),
);
+
return &this->public;
}