Skip to content

Commit

Permalink
(ipsec, psk) writeout base64 instead of plain text, interpret "any" i…
Browse files Browse the repository at this point in the history
…n the process, closes #1205
  • Loading branch information
AdSchellevis committed Sep 29, 2016
1 parent ab3098d commit 57ab36d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/etc/inc/ipsec.inc
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ EOD;

if (!empty($peerid_data)) {
$myid = isset($ph1ent['mobile']) ? trim($myid_data) . " " : "";
$pskconf .= $myid . trim($peerid_data) . " : PSK \"" . trim($ph1ent['pre-shared-key']) . "\"\n";
$pskconf .= $myid . trim($peerid_data) . " : PSK 0s" . base64_encode(trim($ph1ent['pre-shared-key'])) . "\n";
}
}
}
Expand All @@ -794,7 +794,7 @@ EOD;
if (isset($config['system']['user']) && is_array($config['system']['user'])) {
foreach ($config['system']['user'] as $user) {
if (!empty($user['ipsecpsk'])) {
$pskconf .= "{$user['name']} : PSK \"{$user['ipsecpsk']}\"\n";
$pskconf .= "{$user['name']} : PSK 0s".base64_encode($user['ipsecpsk'])."\n";
}
}
unset($user);
Expand All @@ -803,7 +803,12 @@ EOD;
/* add PSKs for mobile clients */
if (isset($ipseccfg['mobilekey'])) {
foreach ($ipseccfg['mobilekey'] as $key) {
$pskconf .= "{$key['ident']} : PSK \"{$key['pre-shared-key']}\"\n";
if (trim(strtolower($key['ident'])) == 'any') {
$ident = '%any';
} else {
$ident = $key['ident'];
}
$pskconf .= "{$ident} : PSK 0s".base64_encode($key['pre-shared-key'])."\n";
}
unset($key);
}
Expand Down

0 comments on commit 57ab36d

Please sign in to comment.