$self->{logger}->log(@_);
}
+ sub agent_info {
+ my $self = shift;
+ my $requesturl = $self->{socket} . '/';
+ my $request = HTTP::Request->new('GET', $requesturl);
+ $self->log('debug', "Contacting MSVA at %s\n", $requesturl);
+ my $response = $self->{ua}->request($request);
+ my $status = $response->status_line;
+ my $ret;
+ if ($status eq '200 OK') {
+ $ret = from_json($response->content);
+ }
+ return $status, $ret;
+ }
+
sub query_agent {
my $self = shift;
my $context = shift;
my $context = shift;
if ($context eq '--help') {
- printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n";
- printf STDERR " msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA\n";
+ printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n";
+ printf STDERR " msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA\n";
+ printf STDERR " msva-query-agent --version\n";
+ exit 0;
+} elsif ($context eq '--version') {
+ my $client = Crypt::Monkeysphere::MSVA::Client->new(
+ socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
+ log_level => $ENV{MSVA_LOG_LEVEL},
+ );
+ my ($status,$ret) = $client->agent_info();
+ $client->log('verbose', "status: %s\n", $status);
+ if (defined $ret) {
+ printf("%s", $ret->{server});
+ printf("\n") if (-t STDOUT);
exit 0;
+ }
+ exit 1;
}
+
my $peer = shift;
my $pkctype = shift;
my $peertype = shift;
my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
-$client->log('info', "status: %s\n", $status);
+$client->log('verbose', "status: %s\n", $status);
if (defined $ret) {
$client->log('info', "valid: %s\n", $ret->{valid});
$client->log('info', "server: %s\n", $ret->{server});
msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
+msva-query-agent --version
+
=head1 ABSTRACT
msva-query-agent validates certificates for a given use by querying a