Ability to view SSL certificates
pull/21/head
Aidaho12 2018-07-13 10:28:21 +06:00
parent d7b3229913
commit 60b83c9c8c
4 changed files with 60 additions and 4 deletions

View File

@ -19,13 +19,23 @@ if form.getvalue('token') is None:
print("What the fuck?! U r hacker Oo?!")
sys.exit()
if form.getvalue('getcert') is not None and serv is not None:
if form.getvalue('getcerts') is not None and serv is not None:
cert_path = funct.get_config_var('haproxy', 'cert_path')
commands = [ "ls -1t /etc/ssl/certs/ |grep pem" ]
try:
funct.ssh_command(serv, commands, ip="1")
except:
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
if form.getvalue('getcert') is not None and serv is not None:
id = form.getvalue('getcert')
cert_path = funct.get_config_var('haproxy', 'cert_path')
commands = [ "cat "+cert_path+"/"+id ]
try:
funct.ssh_command(serv, commands, ip="1")
except:
print('<div class="alert alert-danger" style="margin:0">Can not connect to the server</div>')
if form.getvalue('ssh_cert'):
fullpath = funct.get_config_var('main', 'fullpath')
name = form.getvalue('name')

View File

@ -469,6 +469,10 @@
{{ conf_add }}
</div>
{% endif %}
<div id="dialog-confirm" title="View certificate " style="display: none;">
<p id="dialog-confirm-body"></span></p>
</div>
<script>
$( ".force_close" ).selectmenu({
width: 180

View File

@ -97,7 +97,7 @@
</ul>
</nav>
<div class="copyright-menu">
HAproxy-WI v2.6.2
HAproxy-WI v2.6.2.1
<br>
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 30px; color: red;" class="patreon"> Patreon</a>
</div>

View File

@ -905,7 +905,7 @@ $( function() {
url: "options.py",
data: {
serv: $('#serv5').val(),
getcert: "viewcert",
getcerts: "viewcert",
token: $('#token').val()
},
type: "GET",
@ -914,11 +914,20 @@ $( function() {
$("#ajax-show-ssl").html(data);
} else {
$('.alert-danger').remove();
$( "#ajax-show-ssl").html("<b>"+data+"</b>");
var i;
var new_data = "";
data = data.split("\n");
for (i = 0; i < data.length; i++) {
new_data += ' <a onclick="view_ssl(\''+data[i]+'\')" style="cursor: pointer;" title="View this cert">'+data[i]+'</a> '
}
$("#ajax-show-ssl").html("<b>"+new_data+"</b>");
}
}
} );
});
$('#auth').submit(function() {
$('.alert-danger').remove();
let searchParams = new URLSearchParams(window.location.search)
@ -955,3 +964,36 @@ function replace_text(id_textarea, text_var) {
var text_val = str.substring(0, beg) + str.substring(end, len);
$(id_textarea).text(text_val);
}
function view_ssl(id) {
$.ajax( {
url: "options.py",
data: {
serv: $('#serv5').val(),
getcert: id,
token: $('#token').val()
},
type: "GET",
success: function( data ) {
if (data.indexOf('danger') != '-1') {
$("#ajax-show-ssl").html(data);
} else {
$('.alert-danger').remove();
$('#dialog-confirm-body').text(data);
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "auto",
width: 800,
modal: true,
title: "Certificate from "+$('#serv5').val()+", name: "+id,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
}
}
} );
}