Skip to content

Commit

Permalink
trust: fix API exception on empty CA selection. While here, clear for…
Browse files Browse the repository at this point in the history
…m elements when issuer is empty (which indicates self-signed)
  • Loading branch information
swhite2 committed Aug 6, 2024
1 parent ad0d75c commit c8a44c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function delAction($uuid)
return ['status' => 'failed'];
}

public function caInfoAction($caref)
public function caInfoAction($caref = null)
{
if ($this->request->isGet()) {
$ca = CertStore::getCACertificate($caref);
Expand Down
10 changes: 7 additions & 3 deletions src/opnsense/mvc/app/views/OPNsense/Trust/cert.volt
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,19 @@
if (event.originalEvent !== undefined) {
// not called on form open, only when the user chooses a new ca
ajaxGet('/api/trust/cert/ca_info/' + $(this).val(), {}, function(data, status){
let fields = ['city', 'state', 'country', 'name', 'email', 'organization', 'ocsp_uri'];
if (data.name !== undefined) {
[
'city', 'state', 'country', 'name', 'email', 'organization', 'ocsp_uri'
].forEach(function(field){
fields.forEach(function(field){
if (data[field]) {
$("#cert\\." + field).val(data[field]);
}
});
} else {
fields.forEach(function(field){
$("#cert\\." + field).val('');
});
}

$("#cert\\.country").selectpicker('refresh');
});
}
Expand Down

0 comments on commit c8a44c0

Please sign in to comment.