k8s cmd: use authclient package (#1722)

This commit is contained in:
Caleb Doxsey 2020-12-29 12:06:31 -07:00 committed by GitHub
parent ab44f6b057
commit 796ad2ded8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 134 deletions

View file

@ -1,10 +1,13 @@
package main
import (
"crypto/tls"
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/pomerium/pomerium/pkg/cryptutil"
)
var rootCmd = &cobra.Command{
@ -22,3 +25,18 @@ func fatalf(msg string, args ...interface{}) {
fmt.Fprintf(os.Stderr, msg+"\n", args...)
os.Exit(1)
}
func getTLSConfig(insecureSkipVerify bool, caCert, alternateCAPath string) *tls.Config {
cfg := new(tls.Config)
if insecureSkipVerify {
cfg.InsecureSkipVerify = true
}
if caCert != "" {
var err error
cfg.RootCAs, err = cryptutil.GetCertPool(caCert, alternateCAPath)
if err != nil {
fatalf("%s", err)
}
}
return cfg
}