Debian Codegraph @

modules/caddytls/ech.go

raw symbols SCIP
1 package caddytls
2
3 import (
4 "context"
5 "crypto/tls"
6 "encoding/base64"
7 "encoding/json"
8 "errors"
9 "fmt"
10 "io/fs"
11 weakrand "math/rand/v2"
12 "path"
13 "strconv"
14 "strings"
15 "sync"
16 "time"
17
18 "github.com/caddyserver/certmagic"
19 "github.com/cloudflare/circl/hpke"
20 "github.com/cloudflare/circl/kem"
21 "github.com/libdns/libdns"
22 "go.uber.org/zap"
23 "golang.org/x/crypto/cryptobyte"
24
25 "github.com/caddyserver/caddy/v2"
26 )
27
28 func init() {
29 caddy.RegisterModule(ECHDNSPublisher{})
30 }
31
32 // ECH enables Encrypted ClientHello (ECH) and configures its management.
33 //
34 // ECH helps protect site names (also called "server names" or "domain names"
35 // or "SNI"), which are normally sent over plaintext when establishing a TLS
36 // connection. With ECH, the true ClientHello is encrypted and wrapped by an
37 // "outer" ClientHello that uses a more generic, shared server name that is
38 // publicly known.
39 //
40 // Clients need to know which public name (and other parameters) to use when
41 // connecting to a site with ECH, and the methods for this vary; however,
42 // major browsers support reading ECH configurations from DNS records (which
43 // is typically only secure when DNS-over-HTTPS or DNS-over-TLS is enabled in
44 // the client). Caddy has the ability to automatically publish ECH configs to
45 // DNS records if a DNS provider is configured either in the TLS app or with
46 // each individual publication config object. (Requires a custom build with a
47 // DNS provider module.)
48 //
49 // ECH requires at least TLS 1.3, so any TLS connection policies with ECH
50 // applied will automatically upgrade the minimum TLS version to 1.3, even if
51 // configured to a lower version.
52 //
53 // EXPERIMENTAL: Subject to change.
54 type ECH struct {
55 // The list of ECH configurations for which to automatically generate
56 // and rotate keys. At least one is required to enable ECH.
57 //
58 // It is strongly recommended to use as few ECH configs as possible
59 // to maximize the size of your anonymity set (see the ECH specification
60 // for a definition). Typically, each server should have only one public
61 // name, i.e. one config in this list.
62 Configs []ECHConfiguration `json:"configs,omitempty"`
63
64 // Publication describes ways to publish ECH configs for clients to
65 // discover and use. Without publication, most clients will not use
66 // ECH at all, and those that do will suffer degraded performance.
67 //
68 // Most major browsers support ECH by way of publication to HTTPS
69 // DNS RRs. (This also typically requires that they use DoH or DoT.)
70 Publication []*ECHPublication `json:"publication,omitempty"`
71
72 configsMu *sync.RWMutex // protects both configs and the list of configs/keys the standard library uses
73 configs map[string][]echConfig // map of public_name to list of configs
74 stdlibReady []tls.EncryptedClientHelloKey // ECH configs+keys in a format the standard library can use
75 }
76
77 // Provision loads or creates ECH configs and returns outer names (for certificate
78 // management), but does not publish any ECH configs. The DNS module is used as
79 // a default for later publishing if needed.
80 func (ech *ECH) Provision(ctx caddy.Context) ([]string, error) {
81 ech.configsMu = new(sync.RWMutex)
82
83 logger := ctx.Logger().Named("ech")
84
85 // set up publication modules before we need to obtain a lock in storage,
86 // since this is strictly internal and doesn't require synchronization
87 for i, pub := range ech.Publication {
88 mods, err := ctx.LoadModule(pub, "PublishersRaw")
89 if err != nil {
90 return nil, fmt.Errorf("loading ECH publication modules: %v", err)
91 }
92 for _, modIface := range mods.(map[string]any) {
93 ech.Publication[i].publishers = append(ech.Publication[i].publishers, modIface.(ECHPublisher))
94 }
95 }
96
97 // the rest of provisioning needs an exclusive lock so that instances aren't
98 // stepping on each other when setting up ECH configs
99 storage := ctx.Storage()
100 if err := storage.Lock(ctx, echStorageLockName); err != nil {
101 return nil, err
102 }
103 defer func() {
104 if err := storage.Unlock(ctx, echStorageLockName); err != nil {
105 logger.Error("unable to unlock ECH provisioning in storage", zap.Error(err))
106 }
107 }()
108
109 ech.configsMu.Lock()
110 defer ech.configsMu.Unlock()
111
112 outerNames, err := ech.setConfigsFromStorage(ctx, logger)
113 if err != nil {
114 return nil, fmt.Errorf("loading configs from storage: %w", err)
115 }
116
117 // see if we need to make any new ones based on the input configuration
118 for _, cfg := range ech.Configs {
119 publicName := strings.ToLower(strings.TrimSpace(cfg.PublicName))
120
121 if list, ok := ech.configs[publicName]; !ok || len(list) == 0 {
122 // no config with this public name was loaded, so create one
123 echCfg, err := generateAndStoreECHConfig(ctx, publicName)
124 if err != nil {
125 return nil, err
126 }
127 logger.Debug("generated new ECH config",
128 zap.String("public_name", echCfg.RawPublicName),
129 zap.Uint8("id", echCfg.ConfigID))
130 ech.configs[publicName] = append(ech.configs[publicName], echCfg)
131 outerNames = append(outerNames, publicName)
132 }
133 }
134
135 // convert the configs into a structure ready for the std lib to use
136 ech.updateKeyList()
137
138 // ensure any old keys are rotated out
139 if err = ech.rotateECHKeys(ctx, logger, true); err != nil {
140 return nil, fmt.Errorf("rotating ECH configs: %w", err)
141 }
142
143 return outerNames, nil
144 }
145
146 // setConfigsFromStorage sets the ECH configs in memory to those in storage.
147 // It must be called in a write lock on ech.configsMu.
148 func (ech *ECH) setConfigsFromStorage(ctx caddy.Context, logger *zap.Logger) ([]string, error) {
149 storage := ctx.Storage()
150
151 ech.configs = make(map[string][]echConfig)
152
153 var outerNames []string
154
155 // start by loading all the existing configs (even the older ones on the way out,
156 // since some clients may still be using them if they haven't yet picked up on the
157 // new configs)
158 cfgKeys, err := storage.List(ctx, echConfigsKey, false)
159 if err != nil && !errors.Is(err, fs.ErrNotExist) { // OK if dir doesn't exist; it will be created
160 return nil, err
161 }
162 for _, cfgKey := range cfgKeys {
163 cfg, err := loadECHConfig(ctx, path.Base(cfgKey))
164 if err != nil {
165 return nil, err
166 }
167 // if any part of the config's folder was corrupted, the load function will
168 // clean it up and not return an error, since configs are immutable and
169 // fairly ephemeral... so just check that we actually got a populated config
170 if cfg.configBin == nil || cfg.privKeyBin == nil {
171 continue
172 }
173 logger.Debug("loaded ECH config",
174 zap.String("public_name", cfg.RawPublicName),
175 zap.Uint8("id", cfg.ConfigID))
176 if _, seen := ech.configs[cfg.RawPublicName]; !seen {
177 outerNames = append(outerNames, cfg.RawPublicName)
178 }
179 ech.configs[cfg.RawPublicName] = append(ech.configs[cfg.RawPublicName], cfg)
180 }
181
182 return outerNames, nil
183 }
184
185 // rotateECHKeys updates the ECH keys/configs that are outdated if rotation is needed.
186 // It should be called in a write lock on ech.configsMu. If a lock is already obtained
187 // in storage, then pass true for storageSynced.
188 //
189 // This function sets/updates the stdlib-ready key list only if a rotation occurs.
190 func (ech *ECH) rotateECHKeys(ctx caddy.Context, logger *zap.Logger, storageSynced bool) error {
191 storage := ctx.Storage()
192
193 // all existing configs are now loaded; rotate keys "regularly" as recommended by the spec
194 // (also: "Rotating too frequently limits the client anonymity set." - but the more server
195 // names, the more frequently rotation can be done safely)
196 const (
197 rotationInterval = 24 * time.Hour * 30
198 deleteAfter = 24 * time.Hour * 90
199 )
200
201 if !ech.rotationNeeded(rotationInterval, deleteAfter) {
202 return nil
203 }
204
205 // sync this operation across cluster if not already
206 if !storageSynced {
207 if err := storage.Lock(ctx, echStorageLockName); err != nil {
208 return err
209 }
210 defer func() {
211 if err := storage.Unlock(ctx, echStorageLockName); err != nil {
212 logger.Error("unable to unlock ECH rotation in storage", zap.Error(err))
213 }
214 }()
215 }
216
217 // update what storage has, in case another instance already updated things
218 if _, err := ech.setConfigsFromStorage(ctx, logger); err != nil {
219 return fmt.Errorf("updating ECH keys from storage: %v", err)
220 }
221
222 // iterate the updated list and do any updates as needed
223 for publicName := range ech.configs {
224 for i := 0; i < len(ech.configs[publicName]); i++ {
225 cfg := ech.configs[publicName][i]
226 if time.Since(cfg.meta.Created) >= rotationInterval && cfg.meta.Replaced.IsZero() {
227 // key is due for rotation and it hasn't been replaced yet; do that now
228 logger.Debug("ECH config is due for rotation",
229 zap.String("public_name", cfg.RawPublicName),
230 zap.Uint8("id", cfg.ConfigID),
231 zap.Time("created", cfg.meta.Created),
232 zap.Duration("age", time.Since(cfg.meta.Created)),
233 zap.Duration("rotation_interval", rotationInterval))
234
235 // start by generating and storing the replacement ECH config
236 newCfg, err := generateAndStoreECHConfig(ctx, publicName)
237 if err != nil {
238 return fmt.Errorf("generating and storing new replacement ECH config: %w", err)
239 }
240
241 // mark the key as replaced so we don't rotate it again, and instead delete it later
242 ech.configs[publicName][i].meta.Replaced = time.Now()
243
244 // persist the updated metadata
245 metaBytes, err := json.Marshal(ech.configs[publicName][i].meta)
246 if err != nil {
247 return fmt.Errorf("marshaling updated ECH config metadata: %v", err)
248 }
249 if err := storage.Store(ctx, echMetaKey(cfg.ConfigID), metaBytes); err != nil {
250 return fmt.Errorf("storing updated ECH config metadata: %v", err)
251 }
252
253 ech.configs[publicName] = append(ech.configs[publicName], newCfg)
254
255 logger.Debug("rotated ECH key",
256 zap.String("public_name", cfg.RawPublicName),
257 zap.Uint8("old_id", cfg.ConfigID),
258 zap.Uint8("new_id", newCfg.ConfigID))
259 } else if time.Since(cfg.meta.Created) >= deleteAfter && !cfg.meta.Replaced.IsZero() {
260 // key has expired and is no longer supported; delete it from storage and memory
261 cfgIDKey := path.Join(echConfigsKey, strconv.Itoa(int(cfg.ConfigID)))
262 if err := storage.Delete(ctx, cfgIDKey); err != nil {
263 return fmt.Errorf("deleting expired ECH config: %v", err)
264 }
265
266 ech.configs[publicName] = append(ech.configs[publicName][:i], ech.configs[publicName][i+1:]...)
267 i--
268
269 logger.Debug("deleted expired ECH key",
270 zap.String("public_name", cfg.RawPublicName),
271 zap.Uint8("id", cfg.ConfigID),
272 zap.Duration("age", time.Since(cfg.meta.Created)))
273 }
274 }
275 }
276
277 ech.updateKeyList()
278
279 return nil
280 }
281
282 // rotationNeeded returns true if any ECH key needs to be replaced, or deleted.
283 // It must be called inside a read or write lock of ech.configsMu (probably a
284 // write lock, so that the rotation can occur correctly in the same lock).)
285 func (ech *ECH) rotationNeeded(rotationInterval, deleteAfter time.Duration) bool {
286 for publicName := range ech.configs {
287 for i := 0; i < len(ech.configs[publicName]); i++ {
288 cfg := ech.configs[publicName][i]
289 if (time.Since(cfg.meta.Created) >= rotationInterval && cfg.meta.Replaced.IsZero()) ||
290 (time.Since(cfg.meta.Created) >= deleteAfter && !cfg.meta.Replaced.IsZero()) {
291 return true
292 }
293 }
294 }
295 return false
296 }
297
298 // updateKeyList updates the list of ECH keys the std lib uses to serve ECH.
299 // It must be called inside a write lock on ech.configsMu.
300 func (ech *ECH) updateKeyList() {
301 ech.stdlibReady = []tls.EncryptedClientHelloKey{}
302 for _, cfgs := range ech.configs {
303 for _, cfg := range cfgs {
304 ech.stdlibReady = append(ech.stdlibReady, tls.EncryptedClientHelloKey{
305 Config: cfg.configBin,
306 PrivateKey: cfg.privKeyBin,
307 SendAsRetry: cfg.meta.Replaced.IsZero(), // only send during retries if key has not been rotated out
308 })
309 }
310 }
311 }
312
313 // publishECHConfigs publishes any configs that are configured for publication and which haven't been published already.
314 func (t *TLS) publishECHConfigs(logger *zap.Logger) error {
315 // make publication exclusive, since we don't need to repeat this unnecessarily
316 storage := t.ctx.Storage()
317 const echLockName = "ech_publish"
318 if err := storage.Lock(t.ctx, echLockName); err != nil {
319 return err
320 }
321 defer func() {
322 if err := storage.Unlock(t.ctx, echLockName); err != nil {
323 logger.Error("unable to unlock ECH provisioning in storage", zap.Error(err))
324 }
325 }()
326
327 // get the publication config, or use a default if not specified
328 // (the default publication config should be to publish all ECH
329 // configs to the app-global DNS provider; if no DNS provider is
330 // configured, then this whole function is basically a no-op)
331 publicationList := t.EncryptedClientHello.Publication
332 if publicationList == nil {
333 if dnsProv, ok := t.dns.(ECHDNSProvider); ok {
334 publicationList = []*ECHPublication{
335 {
336 publishers: []ECHPublisher{
337 &ECHDNSPublisher{
338 provider: dnsProv,
339 logger: logger,
340 },
341 },
342 },
343 }
344 }
345 }
346
347 // for each publication config, build the list of ECH configs to
348 // publish with it, and figure out which inner names to publish
349 // to/for, then publish
350 for _, publication := range publicationList {
351 t.EncryptedClientHello.configsMu.RLock()
352 // this publication is either configured for specific ECH configs,
353 // or we just use an implied default of all ECH configs
354 var echCfgList echConfigList
355 var configIDs []uint8 // TODO: use IDs or the outer names?
356 if publication.Configs == nil {
357 // by default, publish all configs
358 for _, configs := range t.EncryptedClientHello.configs {
359 echCfgList = append(echCfgList, configs...)
360 for _, c := range configs {
361 configIDs = append(configIDs, c.ConfigID)
362 }
363 }
364 } else {
365 for _, cfgOuterName := range publication.Configs {
366 if cfgList, ok := t.EncryptedClientHello.configs[cfgOuterName]; ok {
367 echCfgList = append(echCfgList, cfgList...)
368 for _, c := range cfgList {
369 configIDs = append(configIDs, c.ConfigID)
370 }
371 }
372 }
373 }
374 t.EncryptedClientHello.configsMu.RUnlock()
375
376 // marshal the ECH config list as binary for publication
377 echCfgListBin, err := echCfgList.MarshalBinary()
378 if err != nil {
379 return fmt.Errorf("marshaling ECH config list: %v", err)
380 }
381
382 // now we have our list of ECH configs to publish and the inner names
383 // to publish for (i.e. the names being protected); iterate each publisher
384 // and do the publish for any config+name that needs a publish
385 for _, publisher := range publication.publishers {
386 publisherKey := publisher.PublisherKey()
387
388 // by default, publish for all (non-outer) server names, unless
389 // a specific list of names is configured
390 var serverNamesSet map[string]struct{}
391 if publication.Domains == nil {
392 serverNamesSet = make(map[string]struct{}, len(t.serverNames))
393 for name := range t.serverNames {
394 // skip Tailscale names, a special case we also handle differently in our auto-HTTPS
395 if strings.HasSuffix(name, ".ts.net") {
396 continue
397 }
398 serverNamesSet[name] = struct{}{}
399 }
400 } else {
401 serverNamesSet = make(map[string]struct{}, len(publication.Domains))
402 for _, name := range publication.Domains {
403 serverNamesSet[name] = struct{}{}
404 }
405 }
406
407 // remove any domains from the set which have already had all configs in the
408 // list published by this publisher, to avoid always re-publishing unnecessarily
409 for configuredInnerName := range serverNamesSet {
410 allConfigsPublished := true
411 for _, cfg := range echCfgList {
412 // TODO: Potentially utilize the timestamp (map value) for recent-enough publication, instead of just checking for existence
413 if _, ok := cfg.meta.Publications[publisherKey][configuredInnerName]; !ok {
414 allConfigsPublished = false
415 break
416 }
417 }
418 if allConfigsPublished {
419 delete(serverNamesSet, configuredInnerName)
420 }
421 }
422
423 // if all the (inner) domains have had this ECH config list published
424 // by this publisher, then try the next publication config
425 if len(serverNamesSet) == 0 {
426 logger.Debug("ECH config list already published by publisher for associated domains (or no domains to publish for)",
427 zap.Uint8s("config_ids", configIDs),
428 zap.String("publisher", publisherKey))
429 continue
430 }
431
432 // convert the set of names to a slice
433 dnsNamesToPublish := make([]string, 0, len(serverNamesSet))
434 for name := range serverNamesSet {
435 dnsNamesToPublish = append(dnsNamesToPublish, name)
436 }
437
438 logger.Debug("publishing ECH config list",
439 zap.String("publisher", publisherKey),
440 zap.Strings("domains", dnsNamesToPublish),
441 zap.Uint8s("config_ids", configIDs))
442
443 if dnsPublisher, ok := publisher.(*ECHDNSPublisher); ok {
444 dnsPublisher.alpnByDomain = t.alpnValuesForServerNames(dnsNamesToPublish)
445 }
446
447 // publish this ECH config list with this publisher
448 pubTime := time.Now()
449 err := publisher.PublishECHConfigList(t.ctx, dnsNamesToPublish, echCfgListBin)
450
451 var publishErrs PublishECHConfigListErrors
452 if errors.As(err, &publishErrs) {
453 // at least a partial failure, maybe a complete failure, but we can
454 // log each error by domain
455 for innerName, domainErr := range publishErrs {
456 logger.Error("failed to publish ECH configuration list",
457 zap.String("publisher", publisherKey),
458 zap.String("domain", innerName),
459 zap.Uint8s("config_ids", configIDs),
460 zap.Error(domainErr))
461 }
462 } else if err != nil {
463 // generic error; assume the entire thing failed, I guess
464 logger.Error("failed publishing ECH configuration list",
465 zap.String("publisher", publisherKey),
466 zap.Strings("domains", dnsNamesToPublish),
467 zap.Uint8s("config_ids", configIDs),
468 zap.Error(err))
469 }
470
471 if err == nil || (len(publishErrs) > 0 && len(publishErrs) < len(dnsNamesToPublish)) {
472 // if publication for at least some domains succeeded, we should update our publication
473 // state for those domains to avoid unnecessarily republishing every time
474 someAll := "all"
475 if len(publishErrs) > 0 {
476 someAll = "some"
477 }
478 // make a list of names that published successfully with this publisher
479 // so that we update only their state in storage, not the failed ones
480 var successNames []string
481 for _, name := range dnsNamesToPublish {
482 if _, ok := publishErrs[name]; !ok {
483 successNames = append(successNames, name)
484 }
485 }
486 logger.Info("successfully published ECH configuration list for "+someAll+" domains",
487 zap.String("publisher", publisherKey),
488 zap.Strings("domains", successNames),
489 zap.Uint8s("config_ids", configIDs))
490
491 for _, cfg := range echCfgList {
492 if cfg.meta.Publications == nil {
493 cfg.meta.Publications = make(publicationHistory)
494 }
495 if _, ok := cfg.meta.Publications[publisherKey]; !ok {
496 cfg.meta.Publications[publisherKey] = make(map[string]time.Time)
497 }
498 for _, name := range successNames {
499 cfg.meta.Publications[publisherKey][name] = pubTime
500 }
501 metaBytes, err := json.Marshal(cfg.meta)
502 if err != nil {
503 return fmt.Errorf("marshaling ECH config metadata: %v", err)
504 }
505 if err := t.ctx.Storage().Store(t.ctx, echMetaKey(cfg.ConfigID), metaBytes); err != nil {
506 return fmt.Errorf("storing updated ECH config metadata: %v", err)
507 }
508 }
509 } else {
510 logger.Error("all domains failed to publish ECH configuration list (see earlier errors)",
511 zap.String("publisher", publisherKey),
512 zap.Strings("domains", dnsNamesToPublish),
513 zap.Uint8s("config_ids", configIDs))
514 }
515 }
516 }
517
518 return nil
519 }
520
521 // loadECHConfig loads the config from storage with the given configID.
522 // An error is not actually returned in some cases the config fails to
523 // load because in some cases it just means the config ID folder has
524 // been cleaned up in storage, maybe due to an incomplete set of keys
525 // or corrupted contents; in any case, the only rectification is to
526 // delete it and make new keys (an error IS returned if deleting the
527 // corrupted keys fails, for example). Check the returned echConfig for
528 // non-nil privKeyBin and configBin values before using.
529 func loadECHConfig(ctx caddy.Context, configID string) (echConfig, error) {
530 storage := ctx.Storage()
531 logger := ctx.Logger()
532
533 cfgIDKey := path.Join(echConfigsKey, configID)
534 keyKey := path.Join(cfgIDKey, "key.bin")
535 configKey := path.Join(cfgIDKey, "config.bin")
536 metaKey := path.Join(cfgIDKey, "meta.json")
537
538 // if loading anything fails, might as well delete this folder and free up
539 // the config ID; spec is designed to rotate configs frequently anyway
540 // (I consider it a more serious error if we can't clean up the folder,
541 // since leaving stray storage keys is confusing)
542 privKeyBytes, err := storage.Load(ctx, keyKey)
543 if err != nil {
544 delErr := storage.Delete(ctx, cfgIDKey)
545 if delErr != nil {
546 return echConfig{}, fmt.Errorf("error loading private key (%v) and cleaning up parent storage key %s: %v", err, cfgIDKey, delErr)
547 }
548 logger.Warn("could not load ECH private key; deleting its config folder",
549 zap.String("config_id", configID),
550 zap.Error(err))
551 return echConfig{}, nil
552 }
553 echConfigBytes, err := storage.Load(ctx, configKey)
554 if err != nil {
555 delErr := storage.Delete(ctx, cfgIDKey)
556 if delErr != nil {
557 return echConfig{}, fmt.Errorf("error loading ECH config (%v) and cleaning up parent storage key %s: %v", err, cfgIDKey, delErr)
558 }
559 logger.Warn("could not load ECH config; deleting its config folder",
560 zap.String("config_id", configID),
561 zap.Error(err))
562 return echConfig{}, nil
563 }
564 var cfg echConfig
565 if err := cfg.UnmarshalBinary(echConfigBytes); err != nil {
566 delErr := storage.Delete(ctx, cfgIDKey)
567 if delErr != nil {
568 return echConfig{}, fmt.Errorf("error loading ECH config (%v) and cleaning up parent storage key %s: %v", err, cfgIDKey, delErr)
569 }
570 logger.Warn("could not load ECH config; deleted its config folder",
571 zap.String("config_id", configID),
572 zap.Error(err))
573 return echConfig{}, nil
574 }
575 metaBytes, err := storage.Load(ctx, metaKey)
576 if errors.Is(err, fs.ErrNotExist) {
577 logger.Warn("ECH config metadata file missing; will recreate at next publication",
578 zap.String("config_id", configID),
579 zap.Error(err))
580 } else if err != nil {
581 delErr := storage.Delete(ctx, cfgIDKey)
582 if delErr != nil {
583 return echConfig{}, fmt.Errorf("error loading ECH config metadata (%v) and cleaning up parent storage key %s: %v", err, cfgIDKey, delErr)
584 }
585 logger.Warn("could not load ECH config metadata; deleted its folder",
586 zap.String("config_id", configID),
587 zap.Error(err))
588 return echConfig{}, nil
589 }
590 var meta echConfigMeta
591 if len(metaBytes) > 0 {
592 if err := json.Unmarshal(metaBytes, &meta); err != nil {
593 // even though it's just metadata, reset the whole config since we can't reliably maintain it
594 delErr := storage.Delete(ctx, cfgIDKey)
595 if delErr != nil {
596 return echConfig{}, fmt.Errorf("error decoding ECH metadata (%v) and cleaning up parent storage key %s: %v", err, cfgIDKey, delErr)
597 }
598 logger.Warn("could not JSON-decode ECH metadata; deleted its config folder",
599 zap.String("config_id", configID),
600 zap.Error(err))
601 return echConfig{}, nil
602 }
603 }
604
605 cfg.privKeyBin = privKeyBytes
606 cfg.configBin = echConfigBytes
607 cfg.meta = meta
608
609 return cfg, nil
610 }
611
612 func generateAndStoreECHConfig(ctx caddy.Context, publicName string) (echConfig, error) {
613 // Go currently has very strict requirements for server-side ECH configs,
614 // to quote the Go 1.24 godoc (with typos of AEAD IDs corrected):
615 //
616 // "Config should be a marshalled ECHConfig associated with PrivateKey. This
617 // must match the config provided to clients byte-for-byte. The config
618 // should only specify the DHKEM(X25519, HKDF-SHA256) KEM ID (0x0020), the
619 // HKDF-SHA256 KDF ID (0x0001), and a subset of the following AEAD IDs:
620 // AES-128-GCM (0x0001), AES-256-GCM (0x0002), ChaCha20Poly1305 (0x0003)."
621 //
622 // So we need to be sure we generate a config within these parameters
623 // so the Go TLS server can use it.
624
625 // generate a key pair
626 const kemChoice = hpke.KEM_X25519_HKDF_SHA256
627 publicKey, privateKey, err := kemChoice.Scheme().GenerateKeyPair()
628 if err != nil {
629 return echConfig{}, err
630 }
631
632 // find an available config ID
633 configID, err := newECHConfigID(ctx)
634 if err != nil {
635 return echConfig{}, fmt.Errorf("generating unique config ID: %v", err)
636 }
637
638 echCfg := echConfig{
639 PublicKey: publicKey,
640 Version: draftTLSESNI25,
641 ConfigID: configID,
642 RawPublicName: publicName,
643 KEMID: kemChoice,
644 CipherSuites: []hpkeSymmetricCipherSuite{
645 {
646 KDFID: hpke.KDF_HKDF_SHA256,
647 AEADID: hpke.AEAD_AES128GCM,
648 },
649 {
650 KDFID: hpke.KDF_HKDF_SHA256,
651 AEADID: hpke.AEAD_AES256GCM,
652 },
653 {
654 KDFID: hpke.KDF_HKDF_SHA256,
655 AEADID: hpke.AEAD_ChaCha20Poly1305,
656 },
657 },
658 }
659 meta := echConfigMeta{
660 Created: time.Now(),
661 }
662
663 privKeyBytes, err := privateKey.MarshalBinary()
664 if err != nil {
665 return echConfig{}, fmt.Errorf("marshaling ECH private key: %v", err)
666 }
667 echConfigBytes, err := echCfg.MarshalBinary()
668 if err != nil {
669 return echConfig{}, fmt.Errorf("marshaling ECH config: %v", err)
670 }
671 metaBytes, err := json.Marshal(meta)
672 if err != nil {
673 return echConfig{}, fmt.Errorf("marshaling ECH config metadata: %v", err)
674 }
675
676 parentKey := path.Join(echConfigsKey, strconv.Itoa(int(configID)))
677 keyKey := path.Join(parentKey, "key.bin")
678 configKey := path.Join(parentKey, "config.bin")
679 metaKey := path.Join(parentKey, "meta.json")
680
681 if err := ctx.Storage().Store(ctx, keyKey, privKeyBytes); err != nil {
682 return echConfig{}, fmt.Errorf("storing ECH private key: %v", err)
683 }
684 if err := ctx.Storage().Store(ctx, configKey, echConfigBytes); err != nil {
685 return echConfig{}, fmt.Errorf("storing ECH config: %v", err)
686 }
687 if err := ctx.Storage().Store(ctx, metaKey, metaBytes); err != nil {
688 return echConfig{}, fmt.Errorf("storing ECH config metadata: %v", err)
689 }
690
691 echCfg.privKeyBin = privKeyBytes
692 echCfg.configBin = echConfigBytes // this contains the public key
693 echCfg.meta = meta
694
695 return echCfg, nil
696 }
697
698 // ECH represents an Encrypted ClientHello configuration.
699 //
700 // EXPERIMENTAL: Subject to change.
701 type ECHConfiguration struct {
702 // The public server name (SNI) that will be used in the outer ClientHello.
703 // This should be a domain name for which this server is authoritative,
704 // because Caddy will try to provision a certificate for this name. As an
705 // outer SNI, it is never used for application data (HTTPS, etc.), but it
706 // is necessary for enabling clients to connect securely in some cases.
707 // If this field is empty or missing, or if Caddy cannot get a certificate
708 // for this domain (e.g. the domain's DNS records do not point to this server),
709 // client reliability becomes brittle, and you risk coercing clients to expose
710 // true server names in plaintext, which compromises both the privacy of the
711 // server and makes clients more vulnerable.
712 PublicName string `json:"public_name"`
713 }
714
715 // ECHPublication configures publication of ECH config(s). It pairs a list
716 // of ECH configs with the list of domains they are assigned to protect, and
717 // describes how to publish those configs for those domains.
718 //
719 // Most servers will have only a single publication config, unless their
720 // domains are spread across multiple DNS providers or require different
721 // methods of publication.
722 //
723 // EXPERIMENTAL: Subject to change.
724 type ECHPublication struct {
725 // The list of ECH configurations to publish, identified by public name.
726 // If not set, all configs will be included for publication by default.
727 //
728 // It is generally advised to maximize the size of your anonymity set,
729 // which implies using as few public names as possible for your sites.
730 // Usually, only a single public name is used to protect all the sites
731 // for a server
732 //
733 // EXPERIMENTAL: This field may be renamed or have its structure changed.
734 Configs []string `json:"configs,omitempty"`
735
736 // The list of ("inner") domain names which are protected with the associated
737 // ECH configurations.
738 //
739 // If not set, all server names registered with the TLS module will be
740 // added to this list implicitly. (This registration is done automatically
741 // by other Caddy apps that use the TLS module. They should register their
742 // configured server names for this purpose. For example, the HTTP server
743 // registers the hostnames for which it applies automatic HTTPS. This is
744 // not something you, the user, have to do.) Most servers
745 //
746 // Names in this list should not appear in any other publication config
747 // object with the same publishers, since the publications will likely
748 // overwrite each other.
749 //
750 // NOTE: In order to publish ECH configs for domains configured for
751 // On-Demand TLS that are not explicitly enumerated elsewhere in the
752 // config, those domain names will have to be listed here. The only
753 // time Caddy knows which domains it is serving with On-Demand TLS is
754 // handshake-time, which is too late for publishing ECH configs; it
755 // means the first connections would not protect the server names,
756 // revealing that information to observers, and thus defeating the
757 // purpose of ECH. Hence the need to list them here so Caddy can
758 // proactively publish ECH configs before clients connect with those
759 // server names in plaintext.
760 Domains []string `json:"domains,omitempty"`
761
762 // How to publish the ECH configurations so clients can know to use
763 // ECH to connect more securely to the server.
764 PublishersRaw caddy.ModuleMap `json:"publishers,omitempty" caddy:"namespace=tls.ech.publishers"`
765 publishers []ECHPublisher
766 }
767
768 // ECHDNSProvider can service DNS entries for ECH purposes.
769 type ECHDNSProvider interface {
770 libdns.RecordGetter
771 libdns.RecordSetter
772 }
773
774 // ECHDNSPublisher configures how to publish an ECH configuration to
775 // DNS records for the specified domains.
776 //
777 // EXPERIMENTAL: Subject to change.
778 type ECHDNSPublisher struct {
779 // The DNS provider module which will establish the HTTPS record(s).
780 ProviderRaw json.RawMessage `json:"provider,omitempty" caddy:"namespace=dns.providers inline_key=name"`
781 provider ECHDNSProvider
782
783 alpnByDomain map[string][]string
784 logger *zap.Logger
785 }
786
787 // CaddyModule returns the Caddy module information.
788 func (ECHDNSPublisher) CaddyModule() caddy.ModuleInfo {
789 return caddy.ModuleInfo{
790 ID: "tls.ech.publishers.dns",
791 New: func() caddy.Module { return new(ECHDNSPublisher) },
792 }
793 }
794
795 func (dnsPub *ECHDNSPublisher) Provision(ctx caddy.Context) error {
796 dnsProvMod, err := ctx.LoadModule(dnsPub, "ProviderRaw")
797 if err != nil {
798 return fmt.Errorf("loading ECH DNS provider module: %v", err)
799 }
800 prov, ok := dnsProvMod.(ECHDNSProvider)
801 if !ok {
802 return fmt.Errorf("ECH DNS provider module is not an ECH DNS Provider: %v", err)
803 }
804 dnsPub.provider = prov
805 dnsPub.logger = ctx.Logger()
806 return nil
807 }
808
809 // PublisherKey returns the name of the DNS provider module.
810 // We intentionally omit specific provider configuration (or a hash thereof,
811 // since the config is likely sensitive, potentially containing an API key)
812 // because it is unlikely that specific configuration, such as an API key,
813 // is relevant to unique key use as an ECH config publisher.
814 func (dnsPub ECHDNSPublisher) PublisherKey() string {
815 return string(dnsPub.provider.(caddy.Module).CaddyModule().ID)
816 }
817
818 // PublishECHConfigList publishes the given ECH config list (as binary) to the given DNS names.
819 // If there is an error, it may be of type PublishECHConfigListErrors, detailing
820 // potentially multiple errors keyed by associated innerName.
821 func (dnsPub *ECHDNSPublisher) PublishECHConfigList(ctx context.Context, innerNames []string, configListBin []byte) error {
822 nameservers := certmagic.RecursiveNameservers(nil) // TODO: we could make resolvers configurable
823
824 errs := make(PublishECHConfigListErrors)
825
826 nextName:
827 for _, domain := range innerNames {
828 zone, err := certmagic.FindZoneByFQDN(ctx, dnsPub.logger, domain, nameservers)
829 if err != nil {
830 errs[domain] = fmt.Errorf("could not determine zone for domain: %w (domain=%s nameservers=%v)", err, domain, nameservers)
831 continue
832 }
833
834 relName := libdns.RelativeName(domain+".", zone)
835
836 // get existing records for this domain; we need to make sure another
837 // record exists for it so we don't accidentally trample a wildcard; we
838 // also want to get any HTTPS record that may already exist for it so
839 // we can augment the ech SvcParamKey with any other existing SvcParams
840 recs, err := dnsPub.provider.GetRecords(ctx, zone)
841 if err != nil {
842 errs[domain] = fmt.Errorf("unable to get existing DNS records to publish ECH data to HTTPS DNS record: %w", err)
843 continue
844 }
845 var httpsRec libdns.ServiceBinding
846 var nameHasExistingRecord bool
847 for _, rec := range recs {
848 rr := rec.RR()
849 if rr.Name == relName {
850 // CNAME records are exclusive of all other records, so we cannot publish an HTTPS
851 // record for a domain that is CNAME'd. See #6922.
852 if rr.Type == "CNAME" {
853 dnsPub.logger.Warn("domain has CNAME record, so unable to publish ECH data to HTTPS record",
854 zap.String("domain", domain),
855 zap.String("cname_value", rr.Data))
856 continue nextName
857 }
858 nameHasExistingRecord = true
859 if svcb, ok := rec.(libdns.ServiceBinding); ok && svcb.Scheme == "https" {
860 if svcb.Target == "" || svcb.Target == "." {
861 httpsRec = svcb
862 break
863 }
864 }
865 }
866 }
867 if !nameHasExistingRecord {
868 // Turns out if you publish a DNS record for a name that doesn't have any DNS record yet,
869 // any wildcard records won't apply for the name anymore, meaning if a wildcard A/AAAA record
870 // is used to resolve the domain to a server, publishing an HTTPS record could break resolution!
871 // In theory, this should be a non-issue, at least for A/AAAA records, if the HTTPS record
872 // includes ipv[4|6]hint SvcParamKeys,
873 dnsPub.logger.Warn("domain does not have any existing records, so skipping publication of HTTPS record",
874 zap.String("domain", domain),
875 zap.String("relative_name", relName),
876 zap.String("zone", zone))
877 continue
878 }
879 params := httpsRec.Params
880 params = dnsPub.publishedSvcParams(domain, params, configListBin)
881
882 // publish record
883 _, err = dnsPub.provider.SetRecords(ctx, zone, []libdns.Record{
884 libdns.ServiceBinding{
885 // HTTPS and SVCB RRs: RFC 9460 (https://www.rfc-editor.org/rfc/rfc9460)
886 Scheme: "https",
887 Name: relName,
888 TTL: 5 * time.Minute, // TODO: low hard-coded value only temporary; change to a higher value once more field-tested and key rotation is implemented
889 Priority: 2, // allows a manual override with priority 1
890 Target: ".",
891 Params: params,
892 },
893 })
894 if err != nil {
895 errs[domain] = fmt.Errorf("unable to publish ECH data to HTTPS DNS record: %w (zone=%s dns_record_name=%s)", err, zone, relName)
896 continue
897 }
898 }
899
900 if len(errs) > 0 {
901 return errs
902 }
903 return nil
904 }
905
906 func (dnsPub *ECHDNSPublisher) publishedSvcParams(domain string, existing libdns.SvcParams, configListBin []byte) libdns.SvcParams {
907 params := make(libdns.SvcParams, len(existing)+2)
908 for key, values := range existing {
909 params[key] = append([]string(nil), values...)
910 }
911
912 params["ech"] = []string{base64.StdEncoding.EncodeToString(configListBin)}
913
914 if len(dnsPub.alpnByDomain) == 0 {
915 return params
916 }
917
918 if alpn := dnsPub.alpnByDomain[strings.ToLower(domain)]; len(alpn) > 0 {
919 params["alpn"] = append([]string(nil), alpn...)
920 }
921
922 return params
923 }
924
925 // echConfig represents an ECHConfig from the specification,
926 // [draft-ietf-tls-esni-22](https://www.ietf.org/archive/id/draft-ietf-tls-esni-22.html).
927 type echConfig struct {
928 // "The version of ECH for which this configuration is used.
929 // The version is the same as the code point for the
930 // encrypted_client_hello extension. Clients MUST ignore any
931 // ECHConfig structure with a version they do not support."
932 Version uint16
933
934 // The "length" and "contents" fields defined next in the
935 // structure are implicitly taken care of by cryptobyte
936 // when encoding the following fields:
937
938 // HpkeKeyConfig fields:
939 ConfigID uint8
940 KEMID hpke.KEM
941 PublicKey kem.PublicKey
942 CipherSuites []hpkeSymmetricCipherSuite
943
944 // ECHConfigContents fields:
945 MaxNameLength uint8
946 RawPublicName string
947 RawExtensions []byte
948
949 // these fields are not part of the spec, but are here for
950 // our use when setting up TLS servers or maintenance
951 configBin []byte
952 privKeyBin []byte
953 meta echConfigMeta
954 }
955
956 func (echCfg echConfig) MarshalBinary() ([]byte, error) {
957 var b cryptobyte.Builder
958 if err := echCfg.marshalBinary(&b); err != nil {
959 return nil, err
960 }
961 return b.Bytes()
962 }
963
964 // UnmarshalBinary decodes the data back into an ECH config.
965 //
966 // Borrowed from github.com/OmarTariq612/goech with modifications.
967 // Original code: Copyright (c) 2023 Omar Tariq AbdEl-Raziq
968 func (echCfg *echConfig) UnmarshalBinary(data []byte) error {
969 var content cryptobyte.String
970 b := cryptobyte.String(data)
971
972 if !b.ReadUint16(&echCfg.Version) {
973 return errInvalidLen
974 }
975 if echCfg.Version != draftTLSESNI25 {
976 return fmt.Errorf("supported version must be %d: got %d", draftTLSESNI25, echCfg.Version)
977 }
978
979 if !b.ReadUint16LengthPrefixed(&content) || !b.Empty() {
980 return errInvalidLen
981 }
982
983 var t cryptobyte.String
984 var pk []byte
985
986 if !content.ReadUint8(&echCfg.ConfigID) ||
987 !content.ReadUint16((*uint16)(&echCfg.KEMID)) ||
988 !content.ReadUint16LengthPrefixed(&t) ||
989 !t.ReadBytes(&pk, len(t)) ||
990 !content.ReadUint16LengthPrefixed(&t) ||
991 len(t)%4 != 0 /* the length of (KDFs and AEADs) must be divisible by 4 */ {
992 return errInvalidLen
993 }
994
995 if !echCfg.KEMID.IsValid() {
996 return fmt.Errorf("invalid KEM ID: %d", echCfg.KEMID)
997 }
998
999 var err error
1000 if echCfg.PublicKey, err = echCfg.KEMID.Scheme().UnmarshalBinaryPublicKey(pk); err != nil {
1001 return fmt.Errorf("parsing public_key: %w", err)
1002 }
1003
1004 echCfg.CipherSuites = echCfg.CipherSuites[:0]
1005
1006 for !t.Empty() {
1007 var hpkeKDF, hpkeAEAD uint16
1008 if !t.ReadUint16(&hpkeKDF) || !t.ReadUint16(&hpkeAEAD) {
1009 // we have already checked that the length is divisible by 4
1010 panic("this must not happen")
1011 }
1012 if !hpke.KDF(hpkeKDF).IsValid() {
1013 return fmt.Errorf("invalid KDF ID: %d", hpkeKDF)
1014 }
1015 if !hpke.AEAD(hpkeAEAD).IsValid() {
1016 return fmt.Errorf("invalid AEAD ID: %d", hpkeAEAD)
1017 }
1018 echCfg.CipherSuites = append(echCfg.CipherSuites, hpkeSymmetricCipherSuite{
1019 KDFID: hpke.KDF(hpkeKDF),
1020 AEADID: hpke.AEAD(hpkeAEAD),
1021 })
1022 }
1023
1024 var rawPublicName []byte
1025 if !content.ReadUint8(&echCfg.MaxNameLength) ||
1026 !content.ReadUint8LengthPrefixed(&t) ||
1027 !t.ReadBytes(&rawPublicName, len(t)) ||
1028 !content.ReadUint16LengthPrefixed(&t) ||
1029 !t.ReadBytes(&echCfg.RawExtensions, len(t)) ||
1030 !content.Empty() {
1031 return errInvalidLen
1032 }
1033 echCfg.RawPublicName = string(rawPublicName)
1034
1035 return nil
1036 }
1037
1038 var errInvalidLen = errors.New("invalid length")
1039
1040 // marshalBinary writes this config to the cryptobyte builder. If there is an error,
1041 // it will occur before any writes have happened.
1042 func (echCfg echConfig) marshalBinary(b *cryptobyte.Builder) error {
1043 pk, err := echCfg.PublicKey.MarshalBinary()
1044 if err != nil {
1045 return err
1046 }
1047 if l := len(echCfg.RawPublicName); l == 0 || l > 255 {
1048 return fmt.Errorf("public name length (%d) must be in the range 1-255", l)
1049 }
1050
1051 b.AddUint16(echCfg.Version)
1052 b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) { // "length" field
1053 b.AddUint8(echCfg.ConfigID)
1054 b.AddUint16(uint16(echCfg.KEMID))
1055 b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) {
1056 b.AddBytes(pk)
1057 })
1058 b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) {
1059 for _, cs := range echCfg.CipherSuites {
1060 b.AddUint16(uint16(cs.KDFID))
1061 b.AddUint16(uint16(cs.AEADID))
1062 }
1063 })
1064 b.AddUint8(uint8(min(len(echCfg.RawPublicName)+16, 255)))
1065 b.AddUint8LengthPrefixed(func(b *cryptobyte.Builder) {
1066 b.AddBytes([]byte(echCfg.RawPublicName))
1067 })
1068 b.AddUint16LengthPrefixed(func(child *cryptobyte.Builder) {
1069 child.AddBytes(echCfg.RawExtensions)
1070 })
1071 })
1072
1073 return nil
1074 }
1075
1076 type hpkeSymmetricCipherSuite struct {
1077 KDFID hpke.KDF
1078 AEADID hpke.AEAD
1079 }
1080
1081 type echConfigList []echConfig
1082
1083 func (cl echConfigList) MarshalBinary() ([]byte, error) {
1084 var b cryptobyte.Builder
1085 var err error
1086
1087 // the list's length prefixes the list, as with most opaque values
1088 b.AddUint16LengthPrefixed(func(b *cryptobyte.Builder) {
1089 for _, cfg := range cl {
1090 if err = cfg.marshalBinary(b); err != nil {
1091 break
1092 }
1093 }
1094 })
1095 if err != nil {
1096 return nil, err
1097 }
1098
1099 return b.Bytes()
1100 }
1101
1102 func newECHConfigID(ctx caddy.Context) (uint8, error) {
1103 // uint8 can be 0-255 inclusive
1104 const uint8Range = 256
1105
1106 // avoid repeating storage checks
1107 tried := make([]bool, uint8Range)
1108
1109 // Try to find an available number with random rejection sampling;
1110 // i.e. choose a random number and see if it's already taken.
1111 // The hard limit on how many times we try to find an available
1112 // number is flexible... in theory, assuming uniform distribution,
1113 // 256 attempts should make each possible value show up exactly
1114 // once, but obviously that won't be the case. We can try more
1115 // times to try to ensure that every number gets a chance, which
1116 // is especially useful if few are available, or we can lower it
1117 // if we assume we should have found an available value by then
1118 // and want to limit runtime; for now I choose the middle ground
1119 // and just try as many times as there are possible values.
1120 for i := 0; i < uint8Range && ctx.Err() == nil; i++ {
1121 num := uint8(weakrand.N(uint8Range)) //nolint:gosec
1122
1123 // don't try the same number a second time
1124 if tried[num] {
1125 continue
1126 }
1127 tried[num] = true
1128
1129 // check to see if any of the subkeys use this config ID
1130 numStr := strconv.Itoa(int(num))
1131 trialPath := path.Join(echConfigsKey, numStr)
1132 if ctx.Storage().Exists(ctx, trialPath) {
1133 continue
1134 }
1135
1136 return num, nil
1137 }
1138
1139 if err := ctx.Err(); err != nil {
1140 return 0, err
1141 }
1142
1143 return 0, fmt.Errorf("depleted attempts to find an available config_id")
1144 }
1145
1146 // ECHPublisher is an interface for publishing ECHConfigList values
1147 // so that they can be used by clients.
1148 type ECHPublisher interface {
1149 // Returns a key that is unique to this publisher and its configuration.
1150 // A publisher's ID combined with its config is a valid key.
1151 // It is used to prevent duplicating publications.
1152 PublisherKey() string
1153
1154 // Publishes the ECH config list (as binary) for the given innerNames. Some
1155 // publishers may not need a list of inner/protected names, and can ignore the
1156 // argument; most, however, will want to use it to know which inner names are
1157 // to be associated with the given ECH config list.
1158 //
1159 // Implementations should return an error of type PublishECHConfigListErrors
1160 // when relevant to key errors to their associated innerName, but should never
1161 // return a non-nil PublishECHConfigListErrors when its length is 0.
1162 PublishECHConfigList(ctx context.Context, innerNames []string, echConfigList []byte) error
1163 }
1164
1165 // PublishECHConfigListErrors is returned by ECHPublishers to describe one or more
1166 // errors publishing an ECH config list from PublishECHConfigList. A non-nil, empty
1167 // value of this type should never be returned.
1168 // nolint:errname // The linter wants "Error" convention, but this is a multi-error type.
1169 type PublishECHConfigListErrors map[string]error
1170
1171 func (p PublishECHConfigListErrors) Error() string {
1172 var sb strings.Builder
1173 for innerName, err := range p {
1174 if sb.Len() > 0 {
1175 sb.WriteString("; ")
1176 }
1177 sb.WriteString(innerName)
1178 sb.WriteString(": ")
1179 sb.WriteString(err.Error())
1180 }
1181 return sb.String()
1182 }
1183
1184 type echConfigMeta struct {
1185 Created time.Time `json:"created"`
1186 Replaced time.Time `json:"replaced,omitzero"`
1187 Publications publicationHistory `json:"publications"`
1188 }
1189
1190 func echMetaKey(configID uint8) string {
1191 return path.Join(echConfigsKey, strconv.Itoa(int(configID)), "meta.json")
1192 }
1193
1194 // publicationHistory is a map of publisher key to
1195 // map of inner name to timestamp
1196 type publicationHistory map[string]map[string]time.Time
1197
1198 // echStorageLockName is the name of the storage lock to sync ECH updates.
1199 const echStorageLockName = "ech_rotation"
1200
1201 // The key prefix when putting ECH configs in storage. After this
1202 // comes the config ID.
1203 const echConfigsKey = "ech/configs"
1204
1205 // https://www.ietf.org/archive/id/draft-ietf-tls-esni-25.html
1206 const draftTLSESNI25 = 0xfe0d
1207
1208 // Interface guard
1209 var _ ECHPublisher = (*ECHDNSPublisher)(nil)