3 # Monkeysphere Validation Agent Client, Perl version
4 # Copyright © 2010 Jameson Greaf Rollins <jrollins@finestructure.net>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 use Crypt::Monkeysphere::MSVA::Client;
25 if ($context eq '--help') {
26 printf STDERR "Usage: msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] <PKC_DATA\n";
27 printf STDERR " msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA\n";
35 if (!defined $pkcdata) {
36 # load raw pkc data from stdin
43 my $client = Crypt::Monkeysphere::MSVA::Client->new(
44 socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
45 log_level => $ENV{MSVA_LOG_LEVEL},
48 my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
50 $client->log('info', "status: %s\n", $status);
52 $client->log('info', "valid: %s\n", $ret->{valid});
53 $client->log('info', "server: %s\n", $ret->{server});
54 printf("%s", $ret->{message});
55 printf("\n") if (-t STDOUT);
65 msva-query-agent - query a Monkeysphere Validation Agent
69 msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier
71 msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
75 msva-query-agent validates certificates for a given use by querying a
76 running Monkeysphere Validation Agent.
80 msva-query-agent reads a certificate from standard input, and posts it
81 to the running Monkeysphere Validation Agent. The return code
82 indicates the validity (as determined by the agent) of the certificate
83 for the specified purpose. The agent's return message (if any) is
86 The first three command-line arguments are all required, supplied in
93 Context in which the certificate is being validated (e.g. 'https',
98 The name of the intended peer. When validating a certificate for a
99 service, supply the host's full DNS name (e.g. 'foo.example.net')
103 The format of public key carrier data provided on standard input
104 (e.g. 'x509der', 'x509pem', 'opensshpubkey', 'rfc4716', 'openpgp4fpr')
108 The fourth argument is optional:
114 The type of peer we are inquiring about (e.g. 'client', 'server')
116 If 5 arguments are given, the 5th argument is interpreted to be the
117 PKC_DATA itself. This is likely only useful for supplying an OpenPGP
118 fingerprint with the 'openpgp4fpr' type.
124 If the certificate is valid for the requested peer in the given
125 context, the return code is 0. Otherwise, the return code is 1.
127 =head1 ENVIRONMENT VARIABLES
129 msva-query-agent's behavior is controlled by environment variables:
133 =item MONKEYSPHERE_VALIDATION_AGENT_SOCKET
135 Socket over which to query the validation agent. If unset, the
136 default value is 'http://localhost:8901'.
140 Log messages about its operation to stderr. MSVA_LOG_LEVEL controls
141 its verbosity, and should be one of (in increasing verbosity): silent,
142 quiet, fatal, error, info, verbose, debug, debug1, debug2, debug3.
147 =head1 COMMUNICATION PROTOCOL DETAILS
149 Communications with the Monkeysphere Validation Agent are in the form
150 of JSON requests over plain HTTP. Responses from the agent are also
151 JSON objects. For details on the structure of the requests and
152 responses, please see
153 http://web.monkeysphere.info/validation-agent/protocol
157 msva-perl(1), monkeysphere(1), monkeysphere(7)
159 =head1 BUGS AND FEEDBACK
161 Bugs or feature requests for msva-perl and associated tools should be
162 filed with the Monkeysphere project's bug tracker at
163 https://labs.riseup.net/code/projects/monkeysphere/issues/
165 =head1 AUTHORS AND CONTRIBUTORS
167 Jameson Graef Rollins E<lt>jrollins@finestructure.net<gt>
168 Daniel Kahn Gillmor E<lt>dkg@fifthhorseman.net<gt>
170 The Monkeysphere Team http://web.monkeysphere.info/
172 =head1 COPYRIGHT AND LICENSE
174 Copyright © 2010, Jameson Graef Rollins and others from the Monkeysphere
175 team. msva-query-agent is free software, distributed under the GNU
176 Public License, version 3 or later.