MT#5199 Offer API CA Cert for download too.

gjungwirth/fix_tests
Andreas Granig 12 years ago
parent 7d7f7127f2
commit 329b831918

@ -266,6 +266,14 @@ sub api_key :Chained('base') :PathPart('api_key') :Args(0) {
));
$c->res->body($p12);
return;
} elsif ($c->req->body_parameters->{'ca.download'}) {
my $ca_cert = $c->model('CA')->get_server_cert($c);
$c->res->headers(HTTP::Headers->new(
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => sprintf('attachment; filename=%s', "NGCP-API-ca-certificate.pem")
));
$c->res->body($ca_cert);
return;
} elsif ($c->req->body_parameters->{'close'}) {
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for('/administrator'));
return;

@ -55,6 +55,29 @@ has_field 'p12.description' => (
do_label => 0,
);
has_field 'ca' => (
type => 'Compound',
label => 'Download CA Certificate',
do_label => 1,
do_wrapper => 1,
wrapper_class => [qw(row)],
);
has_field 'ca.download' => (
type => 'Submit',
value => 'Download CA Cert',
element_class => [qw(btn btn-tertiary)],
do_wrapper => 0,
do_label => 0,
);
has_field 'ca.description' => (
type => 'Display',
html => '<div class="ngcp-form-desc">The Server Certificate used to sign the above\'s Client Certificates. Needed if you want to verify the server connection in your API client, and the server certificate is not signed by a well-known CA or is self-signed.</div>',
do_wrapper => 0,
do_label => 0,
);
has_field 'del' => (
type => 'Compound',
@ -82,7 +105,7 @@ has_field 'del.description' => (
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(pem p12 del)],
render_list => [qw(pem p12 ca del)],
);
has_field 'close' => (

@ -65,10 +65,11 @@ sub make_pkcs12 {
return $p12;
}
__END__
sub get_server_cert {
my ($self, $c) = @_;
=encoding UTF-8
=head1 NAME
my $cert_file = Path::Tiny->new($c->config->{ssl}->{certfile});
return $cert_file->slurp;
}
NGCP::Panel::Model::CA - certificate management model
# vim: set tabstop=4 expandtab

Loading…
Cancel
Save