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
()
| 182 | // This is the only way to get a config that uses the |
| 183 | // default certificate cache. |
| 184 | func 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 |
no test coverage detected
searching dependent graphs…