use configured tls ca config for all tls connections, so https as well

and add documentation for developers for setting up certificates with manual
local CA (with cfssl) or local ACME CA (with pebble).
This commit is contained in:
Mechiel Lukkien
2023-03-10 16:25:18 +01:00
parent 47b88550be
commit f60ad1452f
5 changed files with 175 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"net"
"net/http"
"net/url"
"os"
"os/user"
@ -344,6 +345,13 @@ func LoadConfig(ctx context.Context, checkACMEHosts bool) []error {
func SetConfig(c *Config) {
// Cannot just assign *c to Conf, it would copy the mutex.
Conf = Config{c.Static, sync.Mutex{}, c.Log, sync.Mutex{}, c.Dynamic, c.dynamicMtime, c.DynamicLastCheck, c.accountDestinations}
// If we have non-standard CA roots, use them for all HTTPS requests.
if Conf.Static.TLS.CertPool != nil {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
RootCAs: Conf.Static.TLS.CertPool,
}
}
}
// ParseConfig parses the static config at path p. If checkOnly is true, no changes