From c8cabf98fba7193189234850f42cfc6257837d99 Mon Sep 17 00:00:00 2001 From: Shawn Bruce Date: Thu, 2 Jan 2014 16:14:31 -0500 Subject: -Added RSA key generation. --- config/tinc/tinc.inc | 17 +++++++++++++++++ config/tinc/tinc_config.xml | 6 ++++++ 2 files changed, 23 insertions(+) (limited to 'config/tinc') diff --git a/config/tinc/tinc.inc b/config/tinc/tinc.inc index cdfb23e5..944cb846 100644 --- a/config/tinc/tinc.inc +++ b/config/tinc/tinc.inc @@ -42,6 +42,22 @@ function tinc_save() { } fwrite($fout, base64_decode($tincconf['extra'])."\n"); fclose($fout); + + // Check if we need to generate a new RSA key pair. + if ($tincconf['gen_rsa']) + { + safe_mkdir("/usr/local/etc/tinc/tmp"); + exec("/usr/local/sbin/tincd -c /usr/local/etc/tinc/tmp -K"); + $tincconf['cert_pub'] = base64_encode(file_get_contents('/usr/local/etc/tinc/tmp/rsa_key.pub')); + $tincconf['cert_key'] = base64_encode(file_get_contents('/usr/local/etc/tinc/tmp/rsa_key.priv')); + $tincconf['gen_rsa'] = false; + $config['installedpackages']['tinc']['config'][0]['cert_pub'] = $tincconf['cert_pub']; + $config['installedpackages']['tinc']['config'][0]['cert_key'] = $tincconf['cert_key']; + $config['installedpackages']['tinc']['config'][0]['gen_rsa'] = $tincconf['gen_rsa']; + rmdir_recursive("/usr/local/etc/tinc/tmp"); + write_config(); + } + $_output = "Subnet=" . $tincconf['localsubnet'] . "\n"; $_output .= base64_decode($tincconf['host_extra']) . "\n"; $_output .= base64_decode($tincconf['cert_pub']) . "\n"; @@ -86,6 +102,7 @@ function tinc_save() { } system("/usr/local/etc/rc.d/tinc.sh restart 2>/dev/null"); rmdir_recursive("/usr/local/etc/tinc.old"); + conf_mount_ro(); config_unlock(); } diff --git a/config/tinc/tinc_config.xml b/config/tinc/tinc_config.xml index 3878450f..d6ee9c26 100644 --- a/config/tinc/tinc_config.xml +++ b/config/tinc/tinc_config.xml @@ -121,6 +121,12 @@ 7 65 + + Generate RSA key pair + gen_rsa + This will generate a new RSA key pair in the fields above. + checkbox + Extra Tinc Parameters extra -- cgit v1.2.3