1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
16 "git.arvados.org/arvados.git/sdk/go/arvados"
17 "github.com/sirupsen/logrus"
20 func tlsConfigWithCertUpdater(cluster *arvados.Cluster, logger logrus.FieldLogger) (*tls.Config, error) {
21 currentCert := make(chan *tls.Certificate, 1)
24 key, cert := cluster.TLS.Key, cluster.TLS.Certificate
25 if !strings.HasPrefix(key, "file://") || !strings.HasPrefix(cert, "file://") {
26 return nil, errors.New("cannot use TLS certificate: TLS.Key and TLS.Certificate must be specified as file://...")
28 key, cert = key[7:], cert[7:]
30 update := func() error {
31 cert, err := tls.LoadX509KeyPair(cert, key)
33 return fmt.Errorf("error loading X509 key pair: %s", err)
36 // Throw away old cert
49 reload := make(chan os.Signal, 1)
50 signal.Notify(reload, syscall.SIGHUP)
54 logger.WithError(err).Warn("error updating TLS certificate")
59 // https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/
61 PreferServerCipherSuites: true,
62 CurvePreferences: []tls.CurveID{
66 MinVersion: tls.VersionTLS12,
67 CipherSuites: []uint16{
68 tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
69 tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
70 tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
71 tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
72 tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
73 tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
75 GetCertificate: func(*tls.ClientHelloInfo) (*tls.Certificate, error) {