GnuPGKey_to_OpenSSH_pub cleanup.
[monkeysphere-validation-agent.git] / msva-perl
1 #!/usr/bin/perl -wT
2
3 # Monkeysphere Validation Agent, Perl version
4 # Copyright © 2010 Daniel Kahn Gillmor <dkg@fifthhorseman.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;
23
24 my $server = Crypt::Monkeysphere::MSVA->new();
25 $server->run(host=>'localhost',
26              log_level=> $server->logger->get_log_level(),
27              user => POSIX::geteuid(),  # explicitly choose regular user and group (avoids spew)
28              group => POSIX::getegid(),
29              msva=>$server);
30 __END__
31
32 =head1 NAME
33
34 msva-perl - Perl implementation of a Monkeysphere Validation Agent
35
36 =head1 SYNOPSIS
37
38   msva-perl [ COMMAND [ ARGS ... ] ]
39
40 =head1 ABSTRACT
41
42 msva-perl provides a Perl implementation of the Monkeysphere
43 Validation Agent, a certificate validation service.
44
45 =head1 INTRODUCTION
46
47 The Monkeysphere Validation Agent offers a local service for tools to
48 validate certificates (both X.509 and OpenPGP) and other public keys.
49
50 Clients of the validation agent query it with a public key carrier (a
51 raw public key, or some flavor of certificate), the supposed name of
52 the remote peer offering the pubkey, and the context in which the
53 validation check is relevant (e.g. ssh, https, etc).
54
55 The validation agent then tells the client whether it was able to
56 successfully validate the peer's use of the public key in the given
57 context.
58
59 =head1 USAGE
60
61 Launched with no arguments, msva-perl simply runs and listens forever.
62
63 Launched with arguments, it sets up a listener, spawns a subprocess
64 using the supplied command and arguments, but with the
65 MONKEYSPHERE_VALIDATION_AGENT_SOCKET environment variable set to refer
66 to its listener.  When the subprocess terminates, msva-perl tears down
67 the listener and exits as well, returning the same value as the
68 subprocess.
69
70 This is a similar invocation pattern to that of ssh-agent(1).
71
72 =head1 ENVIRONMENT VARIABLES
73
74 msva-perl is configured by means of environment variables.
75
76 =over 4
77
78 =item MSVA_LOG_LEVEL
79
80 msva-perl logs messages about its operation to stderr.  MSVA_LOG_LEVEL
81 controls its verbosity, and should be one of (in increasing
82 verbosity): silent, quiet, fatal, error, info, verbose, debug, debug1,
83 debug2, debug3.  Default is 'error'.
84
85 =item MSVA_ALLOWED_USERS
86
87 If your system is capable of it, msva-perl tries to figure out the
88 owner of the connecting client.  If MSVA_ALLOWED_USERS is unset,
89 msva-perl will only permit connections from the user msva is running
90 as.  If you set MSVA_ALLOWED_USERS, msva-perl will treat it as a list
91 of local users (by name or user ID) who are allowed to connect.
92
93 =item MSVA_PORT
94
95 msva-perl listens on a local TCP socket to facilitate access.  You can
96 choose what port to bind to by setting MSVA_PORT.  Default is to bind
97 on an arbitrary open port.
98
99 =item MSVA_KEYSERVER
100
101 msva-perl will request information from OpenPGP keyservers.  Set
102 MSVA_KEYSERVER to declare the keyserver you want it to check with.  If
103 this variable is blank or unset, and your gpg.conf contains a
104 keyserver declaration, it will use the GnuPG configuration.  Failing
105 that, the default is 'hkp://pool.sks-keyservers.net'.
106
107 =item MSVA_KEYSERVER_POLICY
108
109 msva-perl must decide when to check with keyservers (for new keys,
110 revocation certificates, new certifications, etc).  There are three
111 possible options: 'always' means to check with the keyserver on every
112 query it receives.  'never' means to never check with a
113 keyserver. 'unlessvalid' will only check with the keyserver on a
114 specific query if no keys are already locally known to be valid for
115 the requested peer.  Default is 'unlessvalid'.
116
117 =back
118
119 =head1 COMMUNICATION PROTOCOL DETAILS
120
121 Communications with the Monkeysphere Validation Agent are in the form
122 of JSON requests over plain HTTP.  Responses from the agent are also
123 JSON objects.  For details on the structure of the requests and
124 responses, please see
125 http://web.monkeysphere.info/validation-agent/protocol
126
127 =head1 SECURITY CONSIDERATIONS
128
129 msva-perl deliberately binds to the loopback adapter (via named lookup
130 of "localhost") so that remote users do not get access to the daemon.
131 On systems (like Linux) which report ownership of TCP sockets in
132 /proc/net/tcp, msva-perl will refuse access from random users (see
133 MSVA_ALLOWED_USERS above).
134
135 =head1 SEE ALSO
136
137 monkeysphere(1), monkeysphere(7), ssh-agent(1)
138
139 =head1 BUGS AND FEEDBACK
140
141 Bugs or feature requests for msva-perl should be filed with the
142 Monkeysphere project's bug tracker at
143 https://labs.riseup.net/code/projects/monkeysphere/issues/
144
145 =head1 AUTHORS AND CONTRIBUTORS
146
147 Daniel Kahn Gillmor E<lt>dkg@fifthhorseman.net<gt>
148
149 The Monkeysphere Team http://web.monkeysphere.info/
150
151 =head1 COPYRIGHT AND LICENSE
152
153 Copyright © Daniel Kahn Gillmor and others from the Monkeysphere team.
154 msva-perl is free software, distributed under the GNU Public License,
155 version 3 or later.
156