-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathechvars.sh
140 lines (113 loc) · 4.91 KB
/
echvars.sh
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
#!/bin/bash
# set -x
# Copyright (C) 2023 Stephen Farrell, [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ECH keys update as per draft-ietf-tls-wkech-02
# with the addition of 'regeninterval' to the JSON
# and (so far) without support for the 'alias' option
# This is a work-in-progress, DON'T DEPEND ON THIS!!
# This script handles ECH key updating for an ECH front-end (in ECH split-mode),
# back-end (e.g. web server) or zone factory (the thing that publishes DNS RRs
# containing ECH public values).
# variables/settings, some can be overwritten from environment
# where the ECH-enabled OpenSSL is built, needed if ECH-checking is enabled
: ${OSSL:=$HOME/code/openssl}
export LD_LIBRARY_PATH=$OSSL
# script to restart or reload configuations for front/back-end
: ${BE_RESTARTER:=/home/sftcd/bin/be_restart.sh}
: ${FE_RESTARTER:=/home/strcd/bin/fe_restart.sh}
# Top of ECH key file directories
: ${ECHTOP:=$HOME/ech}
# This is where most or all $DURATION-lived ECH keys live
# When they get to 2*$DURATION old they'll be moved to $ECHOLD
ECHDIR="$ECHTOP/echkeydir"
# Where old stuff goes
ECHOLD="$ECHDIR/old"
# Key update frequency - we publish keys for 2 x the "main"
# duration and add a new key each time and retire (as in don't
# load to server) old keys after 3 x this duration.
# So, keys remain usable for 3 x this, and are visible to the
# Internet for 2 x this.
# Old keys are just moved into $ECHOLD for now and are deleted
# once they're 5 x this duration old.
# We request a TTL for that the RR containing keys be half
# this duration.
DURATION="3600" # 1 hour
# Key filename convention is "*.ech" for key files but
# "*.pem.ech" for short-terms key files that'll be moved
# aside
# Long term key files, can be space-sep list if needed
# These won't be expired out ever, and will be added to
# the list of keys we ask be published. This is mostly
# for testing.
: ${LONGTERMKEYS:="$ECHDIR/*.ech"}
# default top of DocRoots
: ${DRTOP:="/var/www"}
# key is FE Origin (host:port), value is DocRoot for that
declare -A fe_arr=(
[cover.defo.ie]="$DRTOP/cover/"
[foo.ie:443]="$DRTOP/foo.ie/www/"
)
# ipv4 and ipv6 hints per FE
declare -A fe_ipv4s=(
[cover.defo.ie]="213.108.108.101"
)
declare -A fe_ipv6s=(
[cover.defo.ie]="2a00:c6c0:0:116:5::10"
)
# key is BE Origin (host:port), value is DocRoot for that
declare -A be_arr=(
[defo.ie]="$DRTOP/defo.ie"
[aliased.defo.ie]="$DRTOP/aliased.defo.ie"
[draft-13.esni.defo.ie:8413]="$DRTOP/draft-13.esni.defo.ie/8413"
[draft-13.esni.defo.ie:8414]="$DRTOP/draft-13.esni.defo.ie/8414"
[draft-13.esni.defo.ie:9413]="$DRTOP/draft-13.esni.defo.ie/9413"
[draft-13.esni.defo.ie:10413]="$DRTOP/draft-13.esni.defo.ie/10413"
[draft-13.esni.defo.ie:11413]="$DRTOP/draft-13.esni.defo.ie/11413"
[draft-13.esni.defo.ie:12413]="$DRTOP/draft-13.esni.defo.ie/12413"
[draft-13.esni.defo.ie:12414]="$DRTOP/draft-13.esni.defo.ie/12414"
)
# key is BE Origin (host:port), value is space-sep list of DNS names,
# or empty string (if we want a signal that ECH is not in use)
# only backends that use aliases need have entries here
declare -A be_alias_arr=(
[alias.esni.defo.ie]="cover.defo.ie cdn.example.net"
)
# key is BE Origin (host:port), value is alias DNS name, or empty string
# only backends that use alpns need have entries here
declare -A be_alpn_arr=(
[defo.ie]="h2,http/1.1"
[draft-13.esni.defo.ie:8413]="http/1.1"
)
# Fixed by draft but may change as we go
WESTR="origin-svcb"
FEWKECHDIR="$FEDOCROOT/.well-known"
FEWKECHFILE="$FEDOCROOT/.well-known/$WESTR"
# uid for writing files to DocRoot, whoever runs this script
# needs to be able to sudo to that uid
: ${WWWUSER:="www-data"}
: ${WWWGRP:="www-data"}
# A timeout in case accessing the FRONTEND .well-known is gonna
# fail - believe it or not: this is 10 seconds
: ${CURLTIMEOUT:="10s"}
# A directory for Zone factory files
: ${ZFDIR:="$HOME/zfdir"}
# A temp dir below that
ZFTMP=$ZFDIR/tmp