aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2006-09-20 05:48:27 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2006-09-20 05:48:27 +0000
commit833a7cbc508b6ef46a8196fdfb1e185d0fc38ae0 (patch)
tree7bfc48db9591c473af2770a34e48b1f7d4b9c656 /src
parentb5cac6684dd884c760d0c2f5596a796ea38e683c (diff)
downloadstrongswan-833a7cbc508b6ef46a8196fdfb1e185d0fc38ae0.tar.bz2
strongswan-833a7cbc508b6ef46a8196fdfb1e185d0fc38ae0.tar.xz
support of encrypted private key files
Diffstat (limited to 'src')
-rw-r--r--src/charon/config/credentials/local_credential_store.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/charon/config/credentials/local_credential_store.c b/src/charon/config/credentials/local_credential_store.c
index 895743f92..db29472eb 100644
--- a/src/charon/config/credentials/local_credential_store.c
+++ b/src/charon/config/credentials/local_credential_store.c
@@ -1011,6 +1011,11 @@ static void load_secrets(private_local_credential_store_t *this)
{
char path[PATH_BUF];
chunk_t filename;
+
+ char buf[BUF_LEN];
+ chunk_t secret = { buf, BUF_LEN };
+ chunk_t *passphrase = NULL;
+
rsa_private_key_t *key;
err_t ugh = extract_value(&filename, &line);
@@ -1038,7 +1043,20 @@ static void load_secrets(private_local_credential_store_t *this)
filename.len, filename.ptr);
}
- key = rsa_private_key_create_from_file(path, NULL);
+ /* check for optional passphrase */
+ if (eat_whitespace(&line))
+ {
+ ugh = extract_secret(&secret, &line);
+ if (ugh != NULL)
+ {
+ this->logger->log(this->logger, ERROR,
+ "line %d: malformed passphrase: %s", line_nr, ugh);
+ goto error;
+ }
+ if (secret.len > 0)
+ passphrase = &secret;
+ }
+ key = rsa_private_key_create_from_file(path, passphrase);
if (key)
{
this->private_keys->insert_last(this->private_keys, (void*)key);