home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / msva-query-agent < prev    next >
Encoding:
Text File  |  2010-12-20  |  4.5 KB  |  162 lines

  1. #!/usr/bin/perl -wT
  2.  
  3. # Monkeysphere Validation Agent Client, Perl version
  4. # Copyright ┬⌐ 2010 Jameson Greaf Rollins <jrollins@finestructure.net>
  5. #
  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.
  10. #
  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.
  15. #
  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/>.
  18.  
  19. use warnings;
  20. use strict;
  21.  
  22. use Crypt::Monkeysphere::MSVA::Client;
  23.  
  24. my $context = shift;
  25. my $peer = shift;
  26. my $pkctype = shift;
  27. my $peertype = shift;
  28.  
  29. # load raw pkc data from stdin
  30. my $pkcdata = do {
  31.   local $/; # slurp!
  32.   <STDIN>;
  33. };
  34.  
  35. my $client = Crypt::Monkeysphere::MSVA::Client->new(
  36.                                                     socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET},
  37.                                                     log_level => $ENV{MSVA_LOG_LEVEL},
  38.                                                    );
  39.  
  40. my ($status,$ret) = $client->query_agent($context,$peer,$peertype,$pkctype,$pkcdata);
  41.  
  42. $client->log('info', "status: %s\n", $status);
  43. if (defined $ret) {
  44.   $client->log('info', "valid: %s\n", $ret->{valid});
  45.   $client->log('info', "server: %s\n", $ret->{server});
  46.   printf("%s\n", $ret->{message});
  47.   exit 0
  48.     if ($ret->{valid});
  49. }
  50. exit 1;
  51.  
  52. __END__
  53.  
  54. =head1 NAME
  55.  
  56. msva-query-agent - query a Monkeysphere Validation Agent
  57.  
  58. =head1 SYNOPSIS
  59.  
  60. msva-query-agent CONTEXT PEER PKC_TYPE [PEER_TYPE] < /path/to/public_key_carrier
  61.  
  62. =head1 ABSTRACT
  63.  
  64. msva-query-agent validates certificates for a given use by querying a
  65. running Monkeysphere Validation Agent.
  66.  
  67. =head1 USAGE
  68.  
  69. msva-query-agent reads a certificate from standard input, and posts it
  70. to the running Monkeysphere Validation Agent.  The return code
  71. indicates the validity (as determined by the agent) of the certificate
  72. for the specified purpose.  The agent's return message (if any) is
  73. emitted on stdout.
  74.  
  75. The first three command-line arguments are all required, supplied in
  76. order, as follows:
  77.  
  78. =over 4
  79.  
  80. =item CONTEXT
  81.  
  82. Context in which the certificate is being validated (e.g. 'https',
  83. 'ssh', 'ike')
  84.  
  85. =item PEER
  86.  
  87. The name of the intended peer.  When validating a certificate for a
  88. service, supply the host's full DNS name (e.g.  'foo.example.net')
  89.  
  90. =item PKC_TYPE
  91.  
  92. The format of public key carrier data provided on standard input
  93. (e.g. 'x509der', 'x509pem', 'opensshpubkey', 'rfc4716')
  94.  
  95. =back
  96.  
  97. The fourth argument is optional:
  98.  
  99. =over 4
  100.  
  101. =item PEER_TYPE
  102.  
  103. The type of peer we are inquiring about (e.g. 'client', 'server')
  104.  
  105. =back
  106.  
  107. =head1 RETURN CODE
  108.  
  109. If the certificate is valid for the requested peer in the given
  110. context, the return code is 0.  Otherwise, the return code is 1.
  111.  
  112. =head1 ENVIRONMENT VARIABLES
  113.  
  114. msva-query-agent's behavior is controlled by environment variables:
  115.  
  116. =over 4
  117.  
  118. =item MONKEYSPHERE_VALIDATION_AGENT_SOCKET
  119.  
  120. Socket over which to query the validation agent.  If unset, the
  121. default value is 'http://localhost:8901'.
  122.  
  123. =item MSVA_LOG_LEVEL
  124.  
  125. Log messages about its operation to stderr.  MSVA_LOG_LEVEL controls
  126. its verbosity, and should be one of (in increasing verbosity): silent,
  127. quiet, fatal, error, info, verbose, debug, debug1, debug2, debug3.
  128. Default is 'error'.
  129.  
  130. =back
  131.  
  132. =head1 COMMUNICATION PROTOCOL DETAILS
  133.  
  134. Communications with the Monkeysphere Validation Agent are in the form
  135. of JSON requests over plain HTTP.  Responses from the agent are also
  136. JSON objects.  For details on the structure of the requests and
  137. responses, please see
  138. http://web.monkeysphere.info/validation-agent/protocol
  139.  
  140. =head1 SEE ALSO
  141.  
  142. msva-perl(1), monkeysphere(1), monkeysphere(7)
  143.  
  144. =head1 BUGS AND FEEDBACK
  145.  
  146. Bugs or feature requests for msva-perl and associated tools should be
  147. filed with the Monkeysphere project's bug tracker at
  148. https://labs.riseup.net/code/projects/monkeysphere/issues/
  149.  
  150. =head1 AUTHORS AND CONTRIBUTORS
  151.  
  152. Jameson Graef Rollins E<lt>jrollins@finestructure.net<gt>
  153. Daniel Kahn Gillmor E<lt>dkg@fifthhorseman.net<gt>
  154.  
  155. The Monkeysphere Team http://web.monkeysphere.info/
  156.  
  157. =head1 COPYRIGHT AND LICENSE
  158.  
  159. Copyright ┬⌐ 2010, Jameson Graef Rollins and others from the Monkeysphere
  160. team.  msva-query-agent is free software, distributed under the GNU
  161. Public License, version 3 or later.
  162.