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;
27 printf STDERR ("Usage: %s CONTEXT PEER PKC_TYPE [PEER_TYPE] < PKC_DATA
28 %s CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
30 ", $name, $name, $name);
34 if ((!defined($context)) ||
35 $context eq '--help') {
37 exit (defined($context) ? 0 : 1);
38 } elsif ($context eq '--version') {
39 my $client = Crypt::Monkeysphere::MSVA::Client->new(
40 socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
41 log_level => $ENV{MSVA_LOG_LEVEL},
43 my ($status,$ret) = $client->agent_info();
44 $client->log('verbose', "status: %s\n", $status);
46 printf("%s", $ret->{server});
57 if (!defined $pkcdata) {
58 # load raw pkc data from stdin
65 my $client = Crypt::Monkeysphere::MSVA::Client->new(
66 socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
67 log_level => $ENV{MSVA_LOG_LEVEL},
70 my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
72 $client->log('verbose', "status: %s\n", $status);
74 $client->log('info', "valid: %s\n", $ret->{valid});
75 $client->log('info', "server: %s\n", $ret->{server});
76 printf("%s", $ret->{message});
83 printf("%s", $status);
91 msva-query-agent - query a Monkeysphere Validation Agent
95 msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier
97 msva-query-agent CONTEXT PEER PKC_TYPE PEER_TYPE PKC_DATA
99 msva-query-agent --version
103 msva-query-agent validates certificates for a given use by querying a
104 running Monkeysphere Validation Agent.
108 msva-query-agent reads a certificate from standard input, and posts it
109 to the running Monkeysphere Validation Agent. The return code
110 indicates the validity (as determined by the agent) of the certificate
111 for the specified purpose. The agent's return message (if any) is
114 The various arguments are:
120 Context in which the certificate is being validated (e.g. 'https',
125 The name of the intended peer. When validating a certificate for a
126 service, supply the host's full DNS name (e.g. 'foo.example.net')
130 The format of public key carrier data provided on standard input
131 (e.g. 'x509der', 'x509pem', 'opensshpubkey', 'rfc4716', 'openpgp4fpr')
135 The type of peer we are inquiring about (e.g. 'client', 'server',
136 'peer'). This argument is optional and defaults will be used (based
137 on CONTEXT) if it is not supplied.
141 This is the actual public key carrier data itself. If less than five
142 arguments are given, then the PKC_DATA is expected on stdin. If five
143 arguments are given, the fifth argument is interpreted as the
144 PKC_DATA. This is likely only useful for supplying an OpenPGP
145 fingerprint with the 'openpgp4fpr' type.
151 If the certificate is valid for the requested peer in the given
152 context, the return code is 0. Otherwise, the return code is 1.
154 =head1 ENVIRONMENT VARIABLES
156 msva-query-agent's behavior is controlled by environment variables:
160 =item MONKEYSPHERE_VALIDATION_AGENT_SOCKET
162 Socket over which to query the validation agent. If unset, the
163 default value is 'http://localhost:8901'.
167 Log messages about its operation to stderr. MSVA_LOG_LEVEL controls
168 its verbosity, and should be one of (in increasing verbosity): silent,
169 quiet, fatal, error, info, verbose, debug, debug1, debug2, debug3.
174 =head1 COMMUNICATION PROTOCOL DETAILS
176 Communications with the Monkeysphere Validation Agent are in the form
177 of JSON requests over plain HTTP. Responses from the agent are also
178 JSON objects. For details on the structure of the requests and
179 responses, please see
180 http://web.monkeysphere.info/validation-agent/protocol
184 msva-perl(1), monkeysphere(1), monkeysphere(7)
186 =head1 BUGS AND FEEDBACK
188 Bugs or feature requests for msva-perl and associated tools should be
189 filed with the Monkeysphere project's bug tracker at
190 https://labs.riseup.net/code/projects/monkeysphere/issues/
192 =head1 AUTHORS AND CONTRIBUTORS
194 Jameson Graef Rollins E<lt>jrollins@finestructure.net<gt>
195 Daniel Kahn Gillmor E<lt>dkg@fifthhorseman.net<gt>
197 The Monkeysphere Team http://web.monkeysphere.info/
199 =head1 COPYRIGHT AND LICENSE
201 Copyright © 2010, Jameson Graef Rollins and others from the Monkeysphere
202 team. msva-query-agent is free software, distributed under the GNU
203 Public License, version 3 or later.