Skip to content

Commit

Permalink
pem
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 14, 2015
1 parent 77346f7 commit 526a251
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion modules/mail/mail_test
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body=$3



(echo "From: nettemp device <$address> "; echo "To: <$reci>"; echo "Subject: $subject"; echo ""; echo -e "$body"; uuencode $4 $4 ) | msmtp \
(echo "From: nettemp device <$address> "; echo "To: <$reci>"; echo "Subject: $subject"; echo ""; echo -e "$body"; uuencode $4 $4 && uuencode $5 $5) | msmtp \
-f $address \
--host=$host --port=$port --auth=$auth --user=$user \
--passwordeval="sqlite3 $dir/dbf/nettemp.db 'SELECT password FROM mail_settings'" \
Expand Down
31 changes: 22 additions & 9 deletions modules/security/radius/EAP_TLS_client
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

user="$1"
mail="$2"
days="$3"
method="$3"
days="$4"

if [[ ! -n "$user" || ! -n "$mail" ]]; then
echo "No user or email or days"
echo "ex. client test [email protected] 365"
if [[ ! -n "$user" || ! -n "$mail" || ! -n "$method" ]]; then
echo "No user or email or days or method"
echo "ex. client test [email protected] p12 365"
exit 0
fi

Expand All @@ -33,16 +34,28 @@ sudo openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12 -p


sudo mv client.p12 users/$user/export.p12
sudo mv client.pem users/$user/$user.pem
sudo mv client.pem users/$user/export.pem
sudo mv client.key users/$user/export.key
sudo mv client.crt users/$user/export.crt
sudo rm $mail.pem
sudo touch users/$user/pass.txt
sudo chmod g+w users/$user/pass.txt
sudo echo "$pass" > users/$user/pass.txt

if [ -s users/$user/export.p12 ]; then
/var/www/nettemp/modules/mail/mail_test $mail "WiFi certificate from RADIUS " "This is Your certificate file and export password, valid $days days: $pass" users/$user/export.p12
else
echo "empty export"

if [ "$method" == "pem" ]; then
if [[ -s users/$user/export.pem && -s users/$user/export.key ]]; then
/var/www/nettemp/modules/mail/mail_test $mail "WiFi certificate from RADIUS " "This is Your certificate file and export password, valid $days days: $pass" "users/$user/export.pem" "users/$user/export.key"
else
echo "No pem or key file"
fi
fi
if [ "$method" == "p12" ]; then
if [ -s users/$user/export.p12 ]; then
/var/www/nettemp/modules/mail/mail_test $mail "WiFi certificate from RADIUS " "This is Your certificate file and export password, valid $days days: $pass" "users/$user/export.p12"
else
echo "No p12 file"
fi
fi

sudo pkill radiusd
Expand Down
19 changes: 14 additions & 5 deletions modules/security/radius/html/certs.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
$mail = isset($_POST['mail']) ? $_POST['mail'] : '';
$days = isset($_POST['days']) ? $_POST['days'] : '';
$add = isset($_POST['add']) ? $_POST['add'] : '';
$method = isset($_POST['method']) ? $_POST['method'] : '';

if ($add == "add"){
shell_exec("modules/security/radius/EAP_TLS_client $username $mail $days");
shell_exec("modules/security/radius/EAP_TLS_client $username $mail $method $days");
header("location: " . $_SERVER['REQUEST_URI']);
exit();
}
Expand All @@ -27,17 +28,24 @@

<div class="table-responsive">
<table class="table table-striped">
<thead><tr><th>Name</th><th>Mail</th><th>Valid days</th><th></th></tr></thead>
<thead><tr><th>Name</th><th>Mail</th><th>Valid days</th><th>Type</th><th></thead>
<tr>
<form action="" method="post" class="form-horizontal">
<div class="form-group">
<td ><input type="text" name="username" value="" class="form-control" required=""/></td>
<td ><input type="text" name="mail" value="" class="form-control" required=""/></td>

<td ><input type="text" name="days" value="" class="form-control" placeholder="ex. 15, default 365 "/></td>
<input type="hidden" name="add" value="add" class="form-control"/>
<td><select name="method" class="form-control">
<option value="p12">p12</option>
<option value="pem">pem</option>
</select>
</td>
<td><button class="btn btn-xs btn-success"><span class="glyphicon glyphicon-plus"></span></button></td>
</div>
</form>

</tr>


Expand All @@ -47,9 +55,9 @@
foreach(glob($Mydir.'*', GLOB_ONLYDIR) as $dir) {
$dir = str_replace($Mydir, '', $dir);

$cmd="sudo openssl x509 -in /usr/local/etc/raddb/certs/users/$dir/$dir.pem -text -noout |grep After| awk '{ print $4\" \"$5\" \"$6\" \"$7}'";
$cmd="sudo openssl x509 -in /usr/local/etc/raddb/certs/users/$dir/export.pem -text -noout |grep After| awk '{ print $4\" \"$5\" \"$6\" \"$7}'";
$out=shell_exec($cmd);
$cmd2="sudo openssl x509 -in /usr/local/etc/raddb/certs/users/$dir/$dir.pem -text -noout |grep 'Subject.*CN'| awk -F\"=\" '{print $6}'";
$cmd2="sudo openssl x509 -in /usr/local/etc/raddb/certs/users/$dir/export.pem -text -noout |grep 'Subject.*CN'| awk -F\"=\" '{print $6}'";
$out2=shell_exec($cmd2);
?>
<tr>
Expand All @@ -62,14 +70,15 @@
<td>
<?php echo "expire: " . $out; ?>
</td>

<td></td>
<td>
<form action="" method="post" style=" display:inline!important;">
<input type="hidden" name="rmuser" value="<?php echo "$dir"; ?>" />
<input type="hidden" name="rmu" value="rmu" />
<button class="btn btn-xs btn-danger">Revoke</button>
</form>
</td>

</tr>
<?php
}
Expand Down

0 comments on commit 526a251

Please sign in to comment.