-
Notifications
You must be signed in to change notification settings - Fork 38
/
ualpn.1
390 lines (390 loc) · 12.3 KB
/
ualpn.1
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
'\" t
.\" Title: ualpn
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/28/2024
.\" Manual: User Commands
.\" Source: ualpn 1.7.5
.\" Language: English
.\"
.TH "UALPN" "1" "01/28/2024" "ualpn 1\&.7\&.5" "User Commands"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ualpn \- lightweight proxying ACMEv2 tls\-alpn\-01 responder
.SH "SYNOPSIS"
.sp
\fBualpn\fR [\fB\-4\fR|\fB\-\-ipv4\fR] [\fB\-6\fR|\fB\-\-ipv6\fR] [\fB\-b\fR|\fB\-\-bind\fR \fIaddress\fR[@\fIport\fR]] [\fB\-c\fR|\fB\-\-connect\fR \fIaddress\fR[@\fIport\fR]] [\fB\-d\fR|\fB\-\-daemon\fR] [\fB\-l\fR|\fB\-\-logfile\fR \fIfile\fR] [\fB\-m\fR|\fB\-\-max\-auths\fR \fIN\fR] [\fB\-n\fR|\fB\-\-num\-workers\fR \fIN\fR] [\fB\-p\fR|\fB\-\-pidfile\fR \fIfile\fR] [\fB\-P\fR|\fB\-\-proxy\fR \fIN\fR] [\fB\-r\fR|\fB\-\-chroot\fR \fIdir\fR] [\fB\-s\fR|\fB\-\-sock\fR \fIpath\fR] [\fB\-S\fR|\fB\-\-sock\-mode\fR \fImode\fR] [\fB\-t\fR|\fB\-\-terminate\fR] [\fB\-u\fR|\fB\-\-user\fR \fIuser\fR[:\fIgroup\fR]] [\fB\-v\fR|\fB\-\-verbose\fR \&...] [\fB\-V\fR|\fB\-\-version\fR] [\fB\-?\fR|\fB\-\-help\fR]
.SH "DESCRIPTION"
.sp
\fBualpn\fR 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)\&.
.sp
Depending on how it is invoked, \fBualpn\fR runs in either client or server mode\&. In client mode \fBualpn\fR 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\&.
.sp
In server mode \fBualpn\fR 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:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
if the connection begins with a "ClientHello" TLS handshake packet including a "acme\-tls/1" RFC7301 Application Level Protocol Negotiation extension
\fBand\fR
a RFC6066 Server Name Indication extension matching an identifier for which it has an authorization,
\fBualpn\fR
performs the tls\-alpn\-01 handshake and closes the connection;
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
otherwise
\fBualpn\fR
transparently proxies the connection to one of the backend servers it is configured with\&. By default
\fBualpn\fR
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\(cqs address to the backend\&. The PROXY protocol is currently supported by apache, nginx and several other server programs\&.
.RE
.sp
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, \fBualpn\fR is able to move network data without copying it to/from kernel/user address space\&.
.SH "OPTIONS"
.PP
\fB\-4, \-\-ipv4\fR
.RS 4
Only listen to IPv4 connections
.RE
.PP
\fB\-6, \-\-ipv6\fR
.RS 4
Only listen to IPv6 connections
.RE
.PP
\fB\-b, \-\-bind\fR \fIaddress\fR[@\fIport\fR]
.RS 4
Enable server mode and listen to
\fIaddress\fR\&. 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,
\fBualpn\fR
listens to the wildcard interface; otherwise it runs in client mode (see CLIENT MODE below)\&.
.RE
.PP
\fB\-c, \-\-connect\fR \fIaddress\fR[@\fIport\fR]
.RS 4
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\&.
.RE
.PP
\fB\-d, \-\-daemon\fR
.RS 4
Enable server mode and fork in the background
.RE
.PP
\fB\-l, \-\-logfile\fR \fIfile\fR
.RS 4
Log to
\fIfile\fR\&. By default
\fBualpn\fR
logs to syslog if
\fB\-d, \-\-daemon\fR
was specified or stderr otherwise\&. See also
\fB\-v, \-\-verbose\fR
.RE
.PP
\fB\-m, \-\-max\-auths\fR \fIN\fR
.RS 4
Enable server mode and allow managing ACMEv2 tls\-alpn\-01 challenges for up to
\fIN\fR
different identifiers (default 100)
.RE
.PP
\fB\-n, \-\-num\-workers\fR \fIN\fR
.RS 4
Enable server mode and spawn
\fIN\fR
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\&.
.RE
.PP
\fB\-p, \-\-pidfile\fR \fIfile\fR
.RS 4
Specify pidfile location (default /var/run/ualpn\&.pid)
.RE
.PP
\fB\-P, \-\-proxy\fR \fIN\fR
.RS 4
Enable server mode and disable (0) or specify (1, 2) the PROXY header version (default 1)\&. The backend server needs to be configured accordingly:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
nginx:
https://docs\&.nginx\&.com/nginx/admin\-guide/load\-balancer/using\-proxy\-protocol
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
apache:
https://httpd\&.apache\&.org/docs/2\&.4/mod/mod_remoteip\&.html#remoteipproxyprotocol
.RE
.RE
.PP
\fB\-r, \-\-chroot\fR \fIdir\fR
.RS 4
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
\fBualpn\fR
will not produce any log output\&.
.RE
.PP
\fB\-s, \-\-sock\fR \fIpath\fR
.RS 4
Specify unix socket path (default /var/run/ualpn\&.sock)
.RE
.PP
\fB\-S, \-\-sock\-mode\fR \fImode\fR
.RS 4
Enable server mode and specify socket access permissions (default 644)
.RE
.PP
\fB\-t, \-\-terminate\fR
.RS 4
Try to terminate a running
\fBualpn\fR
server\&. This is achieved by looking up the process id stored by the server in the pidfile (see
\fB\-p, \-\-pidfile\fR) and signalling it to terminate\&.
.RE
.PP
\fB\-u, \-\-user\fR \fIuser\fR[:\fIgroup\fR]
.RS 4
Enable server mode and drop user (and optionally group) privileges to those of
\fIuser\fR
after binding the sockets\&. Also affects the ownership of the unix socket, pidfile and logfile (if any)\&.
.RE
.PP
\fB\-v, \-\-verbose\fR
.RS 4
By default
\fBualpn\fR
only produces logs upon errors or warnings\&. When this option is specified
\fBualpn\fR
also logs notice messages\&. This option can be specified more than once to increase verbosity and include information (twice) or debug (three times) messages\&.
.RE
.PP
\fB\-V, \-\-version\fR
.RS 4
Print program version on stderr and exit\&.
.RE
.PP
\fB\-?, \-\-help\fR
.RS 4
Print a brief usage text on stderr and exit\&.
.RE
.SH "CLIENT MODE"
.sp
In client mode \fBualpn\fR 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:
.PP
\fBauth\fR \fIidentifier\fR \fIauthorization\fR
.RS 4
The
\fBauth\fR
command instructs the running
\fBualpn\fR
server to handle ACMEv2 tls\-alpn\-01 challenges for
\fIidentifier\fR, 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)\&.
\fIauthorization\fR
must contain the base64url encoding of the SHA\-256 digest of the key authorization computed according to RFC8737 section 3 (note the
\fBuacme\fR
software executes hook scripts with the correct
\fIauthorization\fR
passed as the 5th argument)\&. Upon successful invocation of the
\fBauth\fR
command
\fBualpn\fR
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
\fIidentifier\fR\&.
.RE
.PP
\fBunauth\fR \fIidentifier\fR
.RS 4
The
\fBunauth\fR
command instructs the running
\fBualpn\fR
server to no longer handle ACMEv2 tls\-alpn\-01 challenges for
\fIidentifier\fR\&.
.RE
.sp
\fBualpn\fR responds to both commands with a line beginning with either "OK" or "ERR", followed by a space and additional error information\&.
.SH "EXAMPLES"
.PP
ualpn \-vv \-d \-u nobody:nogroup \-c 127\&.0\&.0\&.1@4443 \-S 666
.RS 4
start
\fBualpn\fR
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\&.
.RE
.PP
echo "auth www\&.example\&.com DEi0apzMOdMT2DAro57oIvn\-wEzPiYcAYDh2Cvjra3I" | ualpn
.RS 4
Instruct the running
\fBualpn\fR
server to handle ACMEv2 tls\-alpn\-01 challenges for www\&.example\&.com with the given key authorization\&.
.RE
.PP
echo "unauth www\&.example\&.com" | ualpn
.RS 4
Instruct the running
\fBualpn\fR
server to no longer handle ACMEv2 tls\-alpn\-01 challenges for www\&.example\&.com
.RE
.SH "EXIT STATUS"
.PP
\fB0\fR
.RS 4
Success
.RE
.PP
\fB1\fR
.RS 4
Failure (syntax or usage error; configuration error; processing failure; unexpected error)\&.
.RE
.SH "EXAMPLE UACME HOOK SCRIPT"
.sp
The \fIualpn\&.sh\fR hook script included in the distribution can be used to automate the certificate issuance with \fBuacme\fR, provided \fBualpn\fR is listening on port 443 of the webserver for the domain being validated
.sp
.if n \{\
.RS 4
.\}
.nf
#!/bin/sh
ARGS=5
E_BADARGS=85
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
if test $# \-ne "$ARGS"
then
echo "Usage: $(basename "$0") method type ident token auth" 1>&2
exit $E_BADARGS
fi
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
METHOD=$1
TYPE=$2
IDENT=$3
TOKEN=$4
AUTH=$5
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
if [ "$TYPE" != "tls\-alpn\-01" ]; then
exit 1
fi
.fi
.if n \{\
.RE
.\}
.sp
.if n \{\
.RS 4
.\}
.nf
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
.fi
.if n \{\
.RE
.\}
.SH "BUGS"
.sp
If you believe you have found a bug, please create a new issue at https://github\&.com/ndilieto/uacme/issues with any applicable information\&.
.SH "SEE ALSO"
.sp
\fBuacme\fR(1)
.SH "AUTHOR"
.sp
\fBualpn\fR was written by Nicola Di Lieto
.SH "COPYRIGHT"
.sp
Copyright \(co 2019\-2024 Nicola Di Lieto <nicola\&.dilieto@gmail\&.com>
.sp
This file is part of \fBuacme\fR\&.
.sp
\fBuacme\fR 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\&.
.sp
\fBuacme\fR 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\&.
.sp
You should have received a copy of the GNU General Public License along with this program\&. If not, see http://www\&.gnu\&.org/licenses/\&.