use warnings;
use strict;
-use Crypt::Monkeysphere::MSVA qw( msvalog );
use Crypt::Monkeysphere::MSVA::Client;
my $context = shift;
+if ($context eq '--help') {
+ printf("Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n");
+ exit 0;
+}
my $peer = shift;
-my $pkctype = shift || 'x509der';
+my $pkctype = shift;
+my $peertype = shift;
# load raw pkc data from stdin
my $pkcdata = do {
<STDIN>;
};
-my ($status,$ret) = Crypt::Monkeysphere::MSVA::Client->query_agent($context,$peer,$pkctype, $pkcdata, $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET});
+my $client = Crypt::Monkeysphere::MSVA::Client->new(
+ socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
+ log_level => $ENV{MSVA_LOG_LEVEL},
+ );
+
+my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
-msvalog('info', "status: %s\n", $status);
+$client->log('info', "status: %s\n", $status);
if (defined $ret) {
- msvalog('info', "valid: %s\n", $ret->{valid});
- msvalog('fatal', "message: %s\n", $ret->{message});
+ $client->log('info', "valid: %s\n", $ret->{valid});
+ $client->log('info', "server: %s\n", $ret->{server});
+ printf("%s\n", $ret->{message});
exit 0
if ($ret->{valid});
}
=head1 SYNOPSIS
-msva-query-agent CONTEXT PEER PKC_TYPE < /path/to/public_key_carrier
+msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier
=head1 ABSTRACT
to the running Monkeysphere Validation Agent. The return code
indicates the validity (as determined by the agent) of the certificate
for the specified purpose. The agent's return message (if any) is
-emitted on stderr.
+emitted on stdout.
-Three command-line arguments are all required, supplied in order, as
-follows:
+The first three command-line arguments are all required, supplied in
+order, as follows:
=over 4
=item PKC_TYPE
The format of public key carrier data provided on standard input
-(e.g. 'x509der')
+(e.g. 'x509der', 'x509pem', 'opensshpubkey', 'rfc4716')
+
+=back
+
+The fourth argument is optional:
+
+=over 4
+
+=item PEER_TYPE
+
+The type of peer we are inquiring about (e.g. 'client', 'server')
=back