From f0ce7b2df91fed66a47bd56cd3d7a0a2bcc210c6 Mon Sep 17 00:00:00 2001 From: Jameson Rollins Date: Tue, 28 Dec 2010 10:20:58 -0500 Subject: [PATCH] add option to msva-query-agent to just return agent version info This option makes only a simple GET request to the agent and returns the agent version portion of the response. --- Crypt/Monkeysphere/MSVA/Client.pm | 14 ++++++++++++++ msva-query-agent | 23 ++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Crypt/Monkeysphere/MSVA/Client.pm b/Crypt/Monkeysphere/MSVA/Client.pm index 046936a..4871e90 100644 --- a/Crypt/Monkeysphere/MSVA/Client.pm +++ b/Crypt/Monkeysphere/MSVA/Client.pm @@ -36,6 +36,20 @@ $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; diff --git a/msva-query-agent b/msva-query-agent index 972037f..3ba8e2a 100755 --- a/msva-query-agent +++ b/msva-query-agent @@ -23,10 +23,25 @@ use Crypt::Monkeysphere::MSVA::Client; my $context = shift; if ($context eq '--help') { - printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] 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; @@ -47,7 +62,7 @@ my $client = Crypt::Monkeysphere::MSVA::Client->new( 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}); @@ -70,6 +85,8 @@ msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier 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 -- 2.26.2