-
Notifications
You must be signed in to change notification settings - Fork 38
/
ualpn.1.txt
287 lines (224 loc) · 10 KB
/
ualpn.1.txt
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
UALPN(1)
========
:doctype: manpage
:man source: ualpn
:man version: {revision}
:man manual: User Commands
NAME
----
ualpn - lightweight proxying ACMEv2 tls-alpn-01 responder
SYNOPSIS
--------
*ualpn* [*-4*|*--ipv4*] [*-6*|*--ipv6*] [*-b*|*--bind* 'address'[@'port']]
[*-c*|*--connect* 'address'[@'port']] [*-d*|*--daemon*]
[*-l*|*--logfile* 'file'] [*-m*|*--max-auths* 'N']
[*-n*|*--num-workers* 'N'] [*-p*|*--pidfile* 'file']
[*-P*|*--proxy* 'N'] [*-r*|*--chroot* 'dir']
[*-s*|*--sock* 'path'] [*-S*|*--sock-mode* 'mode']
[*-t*|*--terminate*] [*-u*|*--user* 'user'`[:`'group']]
[*-v*|*--verbose* ...] [*-V*|*--version*] [*-?*|*--help*]
DESCRIPTION
-----------
*ualpn* is a lightweight proxying ACMEv2 tls-alpn-01 challenge responder
compliant with RFC8737 (<https://tools.ietf.org/html/RFC8737>) and RFC8738
(<https://tools.ietf.org/html/RFC8738>).
Depending on how it is invoked, *ualpn* runs in either client or server mode.
In client mode *ualpn* connects to a running server mode instance of itself
through a unix domain socket, in order to add or remove ACMEv2 authorizations.
See CLIENT MODE below.
In server mode *ualpn* listens for incoming connections (by default on port 443,
which is mandatory for tls-alpn-01 challenges). It then handles any such
connection in one of two different ways:
* if the connection begins with a "ClientHello" TLS handshake packet including a
"acme-tls/1" RFC7301 Application Level Protocol Negotiation extension *and* a
RFC6066 Server Name Indication extension matching an identifier for which it has
an authorization, *ualpn* performs the tls-alpn-01 handshake and closes the
connection;
* otherwise *ualpn* transparently proxies the connection to one of the backend
servers it is configured with. By default *ualpn* adds PROXY v1 headers
(<http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt>) in order to
safely transport connection information such as the client's address to the
backend. The PROXY protocol is currently supported by apache, nginx and several
other server programs.
The event-driven implementation is based on libev (<http://libev.schmorp.de>)
and considerably reduces the cost of context switches and memory usage. In
addition on systems such as Linux supporting the `splice()` system call,
*ualpn* is able to move network data without copying it to/from kernel/user
address space.
OPTIONS
-------
*-4, --ipv4*::
Only listen to IPv4 connections
*-6, --ipv6*::
Only listen to IPv6 connections
*-b, --bind* 'address'[@'port']::
Enable server mode and listen to 'address'. The address must be
specified in numeric format using the standard IPv4 or IPv6 notation.
Optionally, a port number can be given (default is 443). This flag can be
specified multiple times to listen to multiple IP addresses. If this flag
is not specified and server mode was enabled by some other option,
*ualpn* listens to the wildcard interface; otherwise it runs in client
mode (see CLIENT MODE below).
*-c, --connect* 'address'[@'port']::
Enable server mode and add a new backend. The backend address must be
specified in numeric format using the standard IPv4 or IPv6 notation.
Optionally, a port number can be given (default is 443). This flag can be
specified multiple times to add multiple backends. This flag must be
specified at least once in server mode.
*-d, --daemon*::
Enable server mode and fork in the background
*-l, --logfile* 'file'::
Log to 'file'. By default *ualpn* logs to syslog if *-d, --daemon*
was specified or stderr otherwise. See also *-v, --verbose*
*-m, --max-auths* 'N'::
Enable server mode and allow managing ACMEv2 tls-alpn-01 challenges for
up to 'N' different identifiers (default 100)
*-n, --num-workers* 'N'::
Enable server mode and spawn 'N' worker processes (default 2) to
handle connections. Note that worker processes are single threaded but
thanks to the event based implementation each can handle several
(potentially thousands) connections concurrently.
*-p, --pidfile* 'file'::
Specify pidfile location (default {runstatedir}/ualpn.pid)
*-P, --proxy* 'N'::
Enable server mode and disable (0) or specify (1, 2) the PROXY header
version (default 1). The backend server needs to be configured accordingly:
* nginx: <https://docs.nginx.com/nginx/admin-guide/load-balancer/using-proxy-protocol>
* apache: <https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html#remoteipproxyprotocol>
*-r, --chroot* 'dir'::
Enable server mode and specify a directory to chroot to. If logging to
syslog it is necessary to ensure that a syslogd(8) socket is available
at /dev/log in the chroot directory, otherwise *ualpn* will not produce
any log output.
*-s, --sock* 'path'::
Specify unix socket path (default {runstatedir}/ualpn.sock)
*-S, --sock-mode* 'mode'::
Enable server mode and specify socket access permissions (default 644)
*-t, --terminate*::
Try to terminate a running *ualpn* server. This is achieved by looking
up the process id stored by the server in the pidfile (see *-p, --pidfile*)
and signalling it to terminate.
*-u, --user* 'user'`[:`'group'`]`::
Enable server mode and drop user (and optionally group) privileges to those
of 'user' after binding the sockets. Also affects the ownership of the unix
socket, pidfile and logfile (if any).
*-v, --verbose*::
By default *ualpn* only produces logs upon errors or warnings.
When this option is specified *ualpn* also logs notice messages.
This option can be specified more than once to increase verbosity and
include information (twice) or debug (three times) messages.
*-V, --version*::
Print program version on stderr and exit.
*-?, --help*::
Print a brief usage text on stderr and exit.
CLIENT MODE
-----------
In client mode *ualpn* pipes stdin/stdout to/from the unix socket of the
running server instance of itself. The protocol is ASCII text based,
case sensitive, line oriented, with two commands:
*auth* 'identifier' 'authorization'::
The *auth* command instructs the running *ualpn* server to handle ACMEv2
tls-alpn-01 challenges for 'identifier', which can be a string representing
either a domain (type `dns` according to RFC8555 section 9.7.8) or an IP
address (type `ip` according to RFC8738 section 6).
'authorization' must contain the base64url encoding of the SHA-256 digest
of the key authorization computed according to RFC8737 section 3 (note the
*uacme* software executes hook scripts with the correct 'authorization'
passed as the 5th argument).
Upon successful invocation of the *auth* command *ualpn* generates a self
signed certificate as required by the tls-alpn-01 challenge, and then
uses it to perform tls-alpn-01 handshakes for the given 'identifier'.
*unauth* 'identifier'::
The *unauth* command instructs the running *ualpn* server to no longer
handle ACMEv2 tls-alpn-01 challenges for 'identifier'.
*ualpn* responds to both commands with a line beginning with either "OK" or
"ERR", followed by a space and additional error information.
EXAMPLES
--------
`ualpn -vv -d -u nobody:nogroup -c 127.0.0.1@4443 -S 666`::
start *ualpn* as a daemon, binding to the default port 443 on the
wildcard interface. Proxy connections to port 4443 on 127.0.0.1
After opening the sockets, drop the user privileges and run as
nobody:nogroup. Allow anyone on the local host to access the unix
socket. Also increase the verbosity to include notice and
information messages.
`echo "auth www.example.com DEi0apzMOdMT2DAro57oIvn-wEzPiYcAYDh2Cvjra3I" | ualpn`::
Instruct the running *ualpn* server to handle ACMEv2 tls-alpn-01 challenges
for www.example.com with the given key authorization.
`echo "unauth www.example.com" | ualpn`::
Instruct the running *ualpn* server to no longer handle ACMEv2 tls-alpn-01
challenges for www.example.com
EXIT STATUS
-----------
*0*::
Success
*1*::
Failure (syntax or usage error; configuration error;
processing failure; unexpected error).
EXAMPLE UACME HOOK SCRIPT
-------------------------
The 'ualpn.sh' hook script included in the distribution can be used
to automate the certificate issuance with *uacme*, provided *ualpn*
is listening on port 443 of the webserver for the domain being validated
#!/bin/sh
ARGS=5
E_BADARGS=85
if test $# -ne "$ARGS"
then
echo "Usage: $(basename "$0") method type ident token auth" 1>&2
exit $E_BADARGS
fi
METHOD=$1
TYPE=$2
IDENT=$3
TOKEN=$4
AUTH=$5
if [ "$TYPE" != "tls-alpn-01" ]; then
exit 1
fi
case "$METHOD" in
"begin")
UALPN_OUT=$(echo "auth $IDENT $AUTH" | ualpn)
if [ "x$UALPN_OUT" = "xOK" ]; then
exit 0
else
exit 1
fi
;;
"done"|"failed")
UALPN_OUT=$(echo "unauth $IDENT" | ualpn)
if [ "x$UALPN_OUT" = "xOK" ]; then
exit 0
else
exit 1
fi
;;
*)
echo "$0: invalid method" 1>&2
exit 1
esac
BUGS
----
If you believe you have found a bug, please create a new issue
at https://github.com/ndilieto/uacme/issues with any applicable
information.
SEE ALSO
--------
*uacme*(1)
AUTHOR
------
*ualpn* was written by Nicola Di Lieto
COPYRIGHT
---------
Copyright (C) 2019-2024 Nicola Di Lieto <nicola.dilieto@gmail.com>
This file is part of *uacme*.
*uacme* 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.
*uacme* 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/>.