Add a textarea to show the output of the CA.sh
This commit is contained in:
parent
e3f51487ab
commit
7cf991d537
4 changed files with 24 additions and 6 deletions
20
misc/CA.sh
20
misc/CA.sh
|
|
@ -25,6 +25,8 @@ usage()
|
|||
|
||||
[ $# -lt 1 ] && usage
|
||||
|
||||
OUTPUT=`mktemp`
|
||||
|
||||
case $1 in
|
||||
"-newca" )
|
||||
# echo -e -n "${GREEN}Create the directories, take care this will delete"
|
||||
|
|
@ -45,7 +47,11 @@ case $1 in
|
|||
sed -i "s/=.*#DIR/= ${ESCAPED} #DIR/" $OPENSSL_CONF
|
||||
sed -i "s/=.*#CERTTYPE/= server #CERTTYPE/" $OPENSSL_CONF
|
||||
|
||||
pass=`pwgen 10 1`
|
||||
pass=`pwgen 10 1` 2> $OUTPUT
|
||||
if [ $? -ne 0 ]; then
|
||||
cat $OUTPUT
|
||||
exit 5
|
||||
fi
|
||||
|
||||
openssl req -batch -new -keyout ${TOP_DIR}/private/${CAKEY} \
|
||||
-out ${TOP_DIR}/${CAREQ} -passout pass:$pass \
|
||||
|
|
@ -72,7 +78,7 @@ case $1 in
|
|||
echo -e "${GREEN}Signing the Server crt${COLOR_RST}"
|
||||
openssl ca -policy policy_match -out server.crt -infiles server.csr
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Signing failed${COLOR_RST}"
|
||||
echo -e "${RED}Signing failed for new server${COLOR_RST}"
|
||||
rm -rf server.key server.crt server.csr
|
||||
exit 3
|
||||
else
|
||||
|
|
@ -94,7 +100,11 @@ case $1 in
|
|||
sed -i "s/=.*#COMMONNAME/= $2#COMMONNAME/" $OPENSSL_CONF
|
||||
sed -i "s/=.*#CERTTYPE/= client #CERTTYPE/" $OPENSSL_CONF
|
||||
|
||||
pass=`pwgen 10 1`
|
||||
pass=`pwgen 10 1` 2> $OUTPUT
|
||||
if [ $? -ne 0 ]; then
|
||||
cat $OUTPUT
|
||||
exit 5
|
||||
fi
|
||||
|
||||
openssl req -batch -new -keyout ${2}.key -out ${2}.csr \
|
||||
-config ${OPENSSL_CONF} -passout pass:$pass -days ${DAYS}
|
||||
|
|
@ -103,14 +113,14 @@ case $1 in
|
|||
openssl ca -batch -policy policy_match -out ${2}.crt \
|
||||
-config ${OPENSSL_CONF} -infiles ${2}.csr
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Signing failed${COLOR_RST}"
|
||||
echo -e "${RED}Signing failed for $2 ${COLOR_RST}"
|
||||
exit 3
|
||||
fi
|
||||
# echo -e "${GREEN}Export the Client files to pkcs12${COLOR_RST}"
|
||||
openssl pkcs12 -export -inkey ${2}.key -in ${2}.crt -name ${2} \
|
||||
-passin pass:$pass -out ${2}.p12 -passout pass:$pass
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}pkcs12 export failed${COLOR_RST}"
|
||||
echo -e "${RED}pkcs12 export failed${COLOR_RST} for $2"
|
||||
exit 4
|
||||
else
|
||||
echo -e "Exported pkcs12 file is ${2}.p12"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ function new_client($name, $misc_dir)
|
|||
putenv("OPENSSL_CONF=$misc_dir/openssl.cnf");
|
||||
putenv("TOP_DIR=$misc_dir/pki");
|
||||
$output = shell_exec("$misc_dir/CA.sh -newclient $name");
|
||||
return $output;
|
||||
}
|
||||
|
||||
if (!empty($p[2]))
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
|||
$elements = $xpath->query("//teams/team");
|
||||
if (!is_null($elements))
|
||||
{
|
||||
$output = "";
|
||||
foreach ($elements as $element)
|
||||
{
|
||||
$team = new Team();
|
||||
|
|
@ -72,9 +73,10 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
|
|||
if (!empty($team->team_name))
|
||||
{
|
||||
//TODO save the certificate subject
|
||||
new_client($team->team_name, $misc_dir);
|
||||
$output .= new_client($team->team_name, $misc_dir);
|
||||
}
|
||||
}
|
||||
$template->assign("output", $output);
|
||||
}
|
||||
erreur("Fichier XML importé avec succès.", "success");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,9 @@
|
|||
</div>
|
||||
<button type="submit" class="btn btn-primary">Importer</button>
|
||||
</form>
|
||||
|
||||
{if isset($output)}
|
||||
<h2>Output</h2>
|
||||
<pre>{$output}</pre>
|
||||
{/if}
|
||||
{/block}
|
||||
|
|
|
|||
Reference in a new issue