App-CamelPKI
view release on metacpan or search on metacpan
t/04-RevokeByJSON.t view on Meta::CPAN
ok(cert_is_revoked($cert), "Certificate not revoked !");
};
test "Revocation OpenVPNServer" => sub {
my $cert = certify("vpn", "OpenVPNServer", "dns", "test.openvpn.com");
ok(! cert_is_revoked($cert), "Certificate not inserted ?");
revoke("vpn", {"dns", "test.openvpn.com"});
ok(cert_is_revoked($cert), "Certificate not revoked !");
};
test "Revocation OpenVPNServer" => sub {
my $cert = certify("vpn", "OpenVPNClient", "email", 'pki@pki.com');
ok(! cert_is_revoked($cert), "Certificate not inserted ?");
revoke("vpn", {"email", 'pki@pki.com'});
ok(cert_is_revoked($cert), "Certificate not revoked !");
};
=head2 certify($type_cert, $template, $type, $data)
Certify the certificate.
=cut
sub certify {
my ($type_cert, $template, $type, $data) = @_;
my $req = {
"template" => $template,
$type => $data,
};
my $resp_server =
jsoncall_local("http://localhost:3000/ca/template/$type_cert/certifyJSON",
{ "requests" , [ $req ] });
return App::CamelPKI::Certificate->parse($resp_server->{keys}->[0]->[0].$resp_server->{keys}->[0]->[1]);
};
=head2 revoke($type_cert, $type, $data)
revoke the certificate using JSON
=cut
sub revoke{
my ($type_cert, $req) = @_;
my $resp = jsonreq_remote
("https://localhost:$port/ca/template/$type_cert/revokeJSON", $req,
-certificate => $CAcert, -key => $CAkey);
};
=head2 cert_is_revoked($certobj)
Returns true if $certobj is currently in the CRL.
=cut
sub cert_is_revoked {
my $crl = App::CamelPKI::CRL->parse
(plaintextcall_remote("https://localhost:$port/ca/current_crl"));
#print Data::Dumper::Dumper($crl);
my $dlcrl = shift;
return $crl->is_member($dlcrl);
};
( run in 1.630 second using v1.01-cache-2.11-cpan-437f7b0c052 )