@@ -177,6 +177,27 @@ type proxyArg struct {
177177 value string
178178}
179179
180+ type hexArg struct {
181+ value []byte
182+ }
183+
184+ func (a * hexArg ) String () string {
185+ return hex .EncodeToString (a .value )
186+ }
187+
188+ func (a * hexArg ) Set (s string ) error {
189+ b , err := hex .DecodeString (s )
190+ if err != nil {
191+ return err
192+ }
193+ a .value = b
194+ return nil
195+ }
196+
197+ func (a * hexArg ) Value () []byte {
198+ return a .value
199+ }
200+
180201type cacheKind int
181202
182203const (
@@ -210,6 +231,7 @@ type CLIArgs struct {
210231 autocertHTTP string
211232 autocertLocalCacheTTL time.Duration
212233 autocertLocalCacheTimeout time.Duration
234+ autocertCacheEncKey hexArg
213235 passwd string
214236 passwdCost int
215237 hmacSign bool
@@ -290,6 +312,7 @@ func parse_args() CLIArgs {
290312 return nil
291313 })
292314 flag .StringVar (& args .autocertCacheRedisPrefix , "autocert-cache-redis-prefix" , "" , "prefix to use for keys in Redis or Redis Cluster cache" )
315+ flag .Var (& args .autocertCacheEncKey , "autocert-cache-enc-key" , "hex-encoded encryption key for cert cache entries" )
293316 flag .StringVar (& args .autocertACME , "autocert-acme" , autocert .DefaultACMEDirectory , "custom ACME endpoint" )
294317 flag .StringVar (& args .autocertEmail , "autocert-email" , "" , "email used for ACME registration" )
295318 flag .StringVar (& args .autocertHTTP , "autocert-http" , "" , "listen address for HTTP-01 challenges handler of ACME" )
@@ -559,6 +582,13 @@ func run() int {
559582 return 3
560583 }
561584 }
585+ if len (args .autocertCacheEncKey .Value ()) > 0 {
586+ certCache , err = certcache .NewEncryptedCache (args .autocertCacheEncKey .Value (), certCache )
587+ if err != nil {
588+ mainLogger .Critical ("unable to construct cache encryption layer: %v" , err )
589+ return 3
590+ }
591+ }
562592 if args .autocertLocalCacheTTL > 0 {
563593 lcc := certcache .NewLocalCertCache (
564594 certCache ,
0 commit comments