github.com/btccom/go-micro/v2@v2.9.3/api/server/acme/options.go (about)

     1  package acme
     2  
     3  import "github.com/go-acme/lego/v3/challenge"
     4  
     5  // Option (or Options) are passed to New() to configure providers
     6  type Option func(o *Options)
     7  
     8  // Options represents various options you can present to ACME providers
     9  type Options struct {
    10  	// AcceptTLS must be set to true to indicate that you have read your
    11  	// provider's terms of service.
    12  	AcceptToS bool
    13  	// CA is the CA to use
    14  	CA string
    15  	// ChallengeProvider is a go-acme/lego challenge provider. Set this if you
    16  	// want to use DNS Challenges. Otherwise, tls-alpn-01 will be used
    17  	ChallengeProvider challenge.Provider
    18  	// Issue certificates for domains on demand. Otherwise, certs will be
    19  	// retrieved / issued on start-up.
    20  	OnDemand bool
    21  	// Cache is a storage interface. Most ACME libraries have an cache, but
    22  	// there's no defined interface, so if you consume this option
    23  	// sanity check it before using.
    24  	Cache interface{}
    25  }
    26  
    27  // AcceptToS indicates whether you accept your CA's terms of service
    28  func AcceptToS(b bool) Option {
    29  	return func(o *Options) {
    30  		o.AcceptToS = b
    31  	}
    32  }
    33  
    34  // CA sets the CA of an acme.Options
    35  func CA(CA string) Option {
    36  	return func(o *Options) {
    37  		o.CA = CA
    38  	}
    39  }
    40  
    41  // ChallengeProvider sets the Challenge provider of an acme.Options
    42  // if set, it enables the DNS challenge, otherwise tls-alpn-01 will be used.
    43  func ChallengeProvider(p challenge.Provider) Option {
    44  	return func(o *Options) {
    45  		o.ChallengeProvider = p
    46  	}
    47  }
    48  
    49  // OnDemand enables on-demand certificate issuance. Not recommended for use
    50  // with the DNS challenge, as the first connection may be very slow.
    51  func OnDemand(b bool) Option {
    52  	return func(o *Options) {
    53  		o.OnDemand = b
    54  	}
    55  }
    56  
    57  // Cache provides a cache / storage interface to the underlying ACME library
    58  // as there is no standard, this needs to be validated by the underlying
    59  // implentation.
    60  func Cache(c interface{}) Option {
    61  	return func(o *Options) {
    62  		o.Cache = c
    63  	}
    64  }
    65  
    66  // DefaultOptions uses the Let's Encrypt Production CA, with DNS Challenge disabled.
    67  func DefaultOptions() Options {
    68  	return Options{
    69  		AcceptToS: true,
    70  		CA:        LetsEncryptProductionCA,
    71  		OnDemand:  true,
    72  	}
    73  }