/usr/bin/msva-query-agent is in msva-perl 0.9.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | #!/usr/bin/perl -wT
# Monkeysphere Validation Agent Client, Perl version
# Copyright © 2010 Jameson Greaf Rollins <jrollins@finestructure.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use warnings;
use strict;
use Crypt::Monkeysphere::MSVA::Client;
sub usage {
my $name = shift;
printf STDERR ("Usage: %s CONTEXT PEER PKC_TYPE [PEER_TYPE] < PKC_DATA
%s CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
%s --version
", $name, $name, $name);
}
my $context = shift;
if ((!defined($context)) ||
$context eq '--help') {
usage($0);
exit (defined($context) ? 0 : 1);
} 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\n", $ret->{server});
exit 0;
}
exit 1;
}
my $peer = shift;
my $pkctype = shift;
my $peertype = shift;
my $pkcdata = shift;
if (!defined $pkcdata) {
# load raw pkc data from stdin
$pkcdata = do {
local $/; # slurp!
<STDIN>;
};
}
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);
$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});
printf("%s", $ret->{message});
if ($ret->{valid}) {
exit 0
} else {
exit 1;
}
} else {
printf("%s\n", $status);
exit 100;
}
__END__
=encoding utf8
=head1 NAME
msva-query-agent - query a Monkeysphere Validation Agent
=head1 SYNOPSIS
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
running Monkeysphere Validation Agent.
=head1 USAGE
msva-query-agent reads a certificate from standard input, and posts it
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 stdout.
The various arguments are:
=over 4
=item CONTEXT
Context in which the certificate is being validated (e.g. 'https',
'ssh', 'ike')
=item PEER
The name of the intended peer. When validating a certificate for a
service, supply the host's full DNS name (e.g. 'foo.example.net')
=item PKC_TYPE
The format of public key carrier data provided on standard input
(e.g. 'x509der', 'x509pem', 'opensshpubkey', 'rfc4716', 'openpgp4fpr')
=item PEER_TYPE
The type of peer we are inquiring about (e.g. 'client', 'server',
'peer'). This argument is optional and defaults will be used (based
on CONTEXT) if it is not supplied.
=item PKC_DATA
This is the actual public key carrier data itself. If less than five
arguments are given, then the PKC_DATA is expected on stdin. If five
arguments are given, the fifth argument is interpreted as the
PKC_DATA. This is likely only useful for supplying an OpenPGP
fingerprint with the 'openpgp4fpr' type.
=back
=head1 RETURN CODE
If the certificate is valid for the requested peer in the given
context, the return code is 0. Otherwise, the return code is 1.
=head1 ENVIRONMENT VARIABLES
msva-query-agent's behavior is controlled by environment variables:
=over 4
=item MONKEYSPHERE_VALIDATION_AGENT_SOCKET
Socket over which to query the validation agent. If unset, the
default value is 'http://127.0.0.1:8901'.
=item MSVA_LOG_LEVEL
Log messages about its operation to stderr. MSVA_LOG_LEVEL controls
its verbosity, and should be one of (in increasing verbosity): silent,
quiet, fatal, error, info, verbose, debug, debug1, debug2, debug3.
Default is 'error'.
=back
=head1 COMMUNICATION PROTOCOL DETAILS
Communications with the Monkeysphere Validation Agent are in the form
of JSON requests over plain HTTP. Responses from the agent are also
JSON objects. For details on the structure of the requests and
responses, please see
http://web.monkeysphere.info/validation-agent/protocol
=head1 SEE ALSO
msva-perl(1), monkeysphere(1), monkeysphere(7)
=head1 BUGS AND FEEDBACK
Bugs or feature requests for msva-perl and associated tools should be
filed with the Monkeysphere project's bug tracker at
https://labs.riseup.net/code/projects/monkeysphere/issues/
=head1 AUTHORS AND CONTRIBUTORS
Jameson Graef Rollins E<lt>jrollins@finestructure.net<gt>
Daniel Kahn Gillmor E<lt>dkg@fifthhorseman.net<gt>
The Monkeysphere Team http://web.monkeysphere.info/
=head1 COPYRIGHT AND LICENSE
Copyright © 2010, Jameson Graef Rollins and others from the Monkeysphere
team. msva-query-agent is free software, distributed under the GNU
Public License, version 3 or later.
|