MCPcopy Index your code
hub / github.com/caddyserver/certmagic / NewDefault

Function NewDefault

config.go:184–206  ·  view source on GitHub ↗

NewDefault makes a valid config based on the package Default config. Most users will call this function instead of New() since most use cases require only a single config for any and all certificates. If your requirements are more advanced (for example, multiple configs depending on the certificate

()

Source from the content-addressed store, hash-verified

182// This is the only way to get a config that uses the
183// default certificate cache.
184func NewDefault() *Config {
185 defaultCacheMu.Lock()
186 if defaultCache == nil {
187 defaultCache = NewCache(CacheOptions{
188 // the cache will likely need to renew certificates,
189 // so it will need to know how to do that, which
190 // depends on the certificate being managed and which
191 // can change during the lifetime of the cache; this
192 // callback makes it possible to get the latest and
193 // correct config with which to manage the cert,
194 // but if the user does not provide one, we can only
195 // assume that we are to use the default config
196 GetConfigForCert: func(Certificate) (*Config, error) {
197 return NewDefault(), nil
198 },
199 Logger: Default.Logger,
200 })
201 }
202 certCache := defaultCache
203 defaultCacheMu.Unlock()
204
205 return newWithCache(certCache, Default)
206}
207
208// New makes a new, valid config based on cfg and
209// uses the provided certificate cache. certCache

Callers 5

HTTPSFunction · 0.85
TLSFunction · 0.85
ListenFunction · 0.85
ManageSyncFunction · 0.85
ManageAsyncFunction · 0.85

Calls 4

NewCacheFunction · 0.85
newWithCacheFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…