. * * Version 0.1 * Author: Daniel Larraz */ function exists_certificates ($paths) /* ------------------------------------------------------------------------ */ { exec ("sudo ls ".$paths['server_cert'], $sc_cmd); exec ("sudo ls ".$paths['server_key'], $sk_cmd); return $sc_cmd[0] == $paths['server_cert'] && $sk_cmd[0] == $paths['server_key']; } /* ------------------------------------------------------------------------ */ function are_cert_and_key_valid($paths, $key_pass='') /* ------------------------------------------------------------------------ */ { $are_valid = false; $cert_path = $paths['server_cert']; $key_path = $paths['server_key']; $pass_path = $paths['server_pass']; exec ("sudo /etc/ssl/sh/mod_crt.sh $cert_path", $cert); if ($cert[0] == 'VALID_FILE') { // It's OK although it does not need key_pass if ($key_pass == '') { exec ("sudo awk '/echo/ {print $2}' ".$pass_path, $awk); $key_pass = substr($awk[0], 1, -1); } exec ("sudo /etc/ssl/sh/mod_key.sh $key_path $key_pass", $key); if ($key[0] == 'VALID_FILE') { $are_valid = $cert[1] == $key[1]; } } return $are_valid; } /* ------------------------------------------------------------------------ */ ?>