25 lines
801 B
PHP
25 lines
801 B
PHP
#!/usr/bin/php
|
|
<?php
|
|
if (!isset($argv[1])) {
|
|
die("Client name is not specified!\n");
|
|
}
|
|
function readFileOrDie($file)
|
|
{
|
|
if (!file_exists($file)) {
|
|
die("File " . $file . " not found!\n");
|
|
}
|
|
return file_get_contents($file);
|
|
}
|
|
|
|
function wrap($what, $tag)
|
|
{
|
|
return "<" . $tag . ">" . $what . "</" . $tag . ">\n";
|
|
}
|
|
|
|
$clientName = $argv[1];
|
|
$template = readFileOrDie("/data/client-config-template.conf");
|
|
$template .= "\n";
|
|
$template .= wrap(readFileOrDie("/data/pki/issued/" . $clientName . ".crt"), "cert");
|
|
$template .= wrap(readFileOrDie("/data/pki/ca.crt"), "ca");
|
|
$template .= wrap(readFileOrDie("/data/pki/private/" . $clientName . ".key"), "key");
|
|
echo "\n\n\nYour config is: \n ================================\n\n" . $template . "\n\n===============================\n"; |