2022-10-13 08:01:23 -06:00
|
|
|
package hsic
|
|
|
|
|
|
|
|
import (
|
2022-11-02 02:55:09 -06:00
|
|
|
"bytes"
|
2022-11-06 12:22:21 -07:00
|
|
|
"crypto/rand"
|
|
|
|
"crypto/rsa"
|
|
|
|
"crypto/tls"
|
|
|
|
"crypto/x509"
|
|
|
|
"crypto/x509/pkix"
|
2022-10-13 08:01:23 -06:00
|
|
|
"encoding/json"
|
2022-11-06 12:22:21 -07:00
|
|
|
"encoding/pem"
|
2022-10-13 08:01:23 -06:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2022-11-06 12:22:21 -07:00
|
|
|
"math/big"
|
|
|
|
"net"
|
2022-10-13 08:01:23 -06:00
|
|
|
"net/http"
|
2022-11-06 12:22:21 -07:00
|
|
|
"time"
|
2022-10-13 08:01:23 -06:00
|
|
|
|
|
|
|
"github.com/juanfont/headscale"
|
|
|
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
|
|
|
"github.com/juanfont/headscale/integration/dockertestutil"
|
2022-11-06 12:22:21 -07:00
|
|
|
"github.com/juanfont/headscale/integration/integrationutil"
|
2022-10-13 08:01:23 -06:00
|
|
|
"github.com/ory/dockertest/v3"
|
|
|
|
)
|
|
|
|
|
2022-10-18 04:09:10 -06:00
|
|
|
const (
|
2022-11-06 12:22:21 -07:00
|
|
|
hsicHashLength = 6
|
|
|
|
dockerContextPath = "../."
|
|
|
|
aclPolicyPath = "/etc/headscale/acl.hujson"
|
|
|
|
tlsCertPath = "/etc/headscale/tls.cert"
|
|
|
|
tlsKeyPath = "/etc/headscale/tls.key"
|
|
|
|
headscaleDefaultPort = 8080
|
2022-10-18 04:09:10 -06:00
|
|
|
)
|
2022-10-13 08:01:23 -06:00
|
|
|
|
|
|
|
var errHeadscaleStatusCodeNotOk = errors.New("headscale status code not ok")
|
|
|
|
|
|
|
|
type HeadscaleInContainer struct {
|
|
|
|
hostname string
|
|
|
|
|
|
|
|
pool *dockertest.Pool
|
|
|
|
container *dockertest.Resource
|
|
|
|
network *dockertest.Network
|
2022-11-02 04:08:54 -06:00
|
|
|
|
|
|
|
// optional config
|
2022-11-06 12:22:21 -07:00
|
|
|
port int
|
2022-11-02 04:08:54 -06:00
|
|
|
aclPolicy *headscale.ACLPolicy
|
|
|
|
env []string
|
2022-11-06 12:22:21 -07:00
|
|
|
tlsCert []byte
|
|
|
|
tlsKey []byte
|
2022-11-02 04:08:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type Option = func(c *HeadscaleInContainer)
|
|
|
|
|
|
|
|
func WithACLPolicy(acl *headscale.ACLPolicy) Option {
|
|
|
|
return func(hsic *HeadscaleInContainer) {
|
2022-11-06 12:22:21 -07:00
|
|
|
// TODO(kradalby): Move somewhere appropriate
|
|
|
|
hsic.env = append(hsic.env, fmt.Sprintf("HEADSCALE_ACL_POLICY_PATH=%s", aclPolicyPath))
|
|
|
|
|
2022-11-02 04:08:54 -06:00
|
|
|
hsic.aclPolicy = acl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
func WithTLS() Option {
|
|
|
|
return func(hsic *HeadscaleInContainer) {
|
|
|
|
cert, key, err := createCertificate()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("failed to create certificates for headscale test: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(kradalby): Move somewhere appropriate
|
|
|
|
hsic.env = append(hsic.env, fmt.Sprintf("HEADSCALE_TLS_CERT_PATH=%s", tlsCertPath))
|
|
|
|
hsic.env = append(hsic.env, fmt.Sprintf("HEADSCALE_TLS_KEY_PATH=%s", tlsKeyPath))
|
|
|
|
hsic.env = append(hsic.env, "HEADSCALE_TLS_CLIENT_AUTH_MODE=disabled")
|
|
|
|
|
|
|
|
hsic.tlsCert = cert
|
|
|
|
hsic.tlsKey = key
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-02 04:08:54 -06:00
|
|
|
func WithConfigEnv(configEnv map[string]string) Option {
|
|
|
|
return func(hsic *HeadscaleInContainer) {
|
|
|
|
env := []string{}
|
|
|
|
|
|
|
|
for key, value := range configEnv {
|
|
|
|
env = append(env, fmt.Sprintf("%s=%s", key, value))
|
|
|
|
}
|
|
|
|
|
|
|
|
hsic.env = env
|
|
|
|
}
|
2022-10-13 08:01:23 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
func WithPort(port int) Option {
|
|
|
|
return func(hsic *HeadscaleInContainer) {
|
|
|
|
hsic.port = port
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
func New(
|
|
|
|
pool *dockertest.Pool,
|
2022-10-18 04:09:10 -06:00
|
|
|
network *dockertest.Network,
|
2022-11-02 04:08:54 -06:00
|
|
|
opts ...Option,
|
2022-10-18 04:09:10 -06:00
|
|
|
) (*HeadscaleInContainer, error) {
|
2022-10-13 08:01:23 -06:00
|
|
|
hash, err := headscale.GenerateRandomStringDNSSafe(hsicHashLength)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-11-02 04:08:54 -06:00
|
|
|
hostname := fmt.Sprintf("hs-%s", hash)
|
|
|
|
|
|
|
|
hsic := &HeadscaleInContainer{
|
|
|
|
hostname: hostname,
|
2022-11-06 12:22:21 -07:00
|
|
|
port: headscaleDefaultPort,
|
2022-11-02 04:08:54 -06:00
|
|
|
|
|
|
|
pool: pool,
|
|
|
|
network: network,
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(hsic)
|
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
portProto := fmt.Sprintf("%d/tcp", hsic.port)
|
2022-11-02 04:08:54 -06:00
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
headscaleBuildOptions := &dockertest.BuildOptions{
|
2022-11-02 02:53:55 -06:00
|
|
|
Dockerfile: "Dockerfile.debug",
|
2022-10-13 08:01:23 -06:00
|
|
|
ContextDir: dockerContextPath,
|
|
|
|
}
|
|
|
|
|
|
|
|
runOptions := &dockertest.RunOptions{
|
2022-11-02 02:55:48 -06:00
|
|
|
Name: hostname,
|
2022-10-13 08:01:23 -06:00
|
|
|
ExposedPorts: []string{portProto},
|
2022-11-02 02:55:48 -06:00
|
|
|
Networks: []*dockertest.Network{network},
|
|
|
|
// Cmd: []string{"headscale", "serve"},
|
|
|
|
// TODO(kradalby): Get rid of this hack, we currently need to give us some
|
|
|
|
// to inject the headscale configuration further down.
|
|
|
|
Entrypoint: []string{"/bin/bash", "-c", "/bin/sleep 3 ; headscale serve"},
|
2022-11-02 04:08:54 -06:00
|
|
|
Env: hsic.env,
|
2022-10-13 08:01:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// dockertest isnt very good at handling containers that has already
|
|
|
|
// been created, this is an attempt to make sure this container isnt
|
|
|
|
// present.
|
|
|
|
err = pool.RemoveContainerByName(hostname)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
container, err := pool.BuildAndRunWithBuildOptions(
|
|
|
|
headscaleBuildOptions,
|
|
|
|
runOptions,
|
|
|
|
dockertestutil.DockerRestartPolicy,
|
|
|
|
dockertestutil.DockerAllowLocalIPv6,
|
|
|
|
dockertestutil.DockerAllowNetworkAdministration,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not start headscale container: %w", err)
|
|
|
|
}
|
|
|
|
log.Printf("Created %s container\n", hostname)
|
|
|
|
|
2022-11-02 04:08:54 -06:00
|
|
|
hsic.container = container
|
2022-11-02 02:55:48 -06:00
|
|
|
|
|
|
|
err = hsic.WriteFile("/etc/headscale/config.yaml", []byte(DefaultConfigYAML()))
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to write headscale config to container: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-11-02 04:08:54 -06:00
|
|
|
if hsic.aclPolicy != nil {
|
|
|
|
data, err := json.Marshal(hsic.aclPolicy)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to marshal ACL Policy to JSON: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = hsic.WriteFile(aclPolicyPath, data)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to write ACL policy to container: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
if hsic.hasTLS() {
|
|
|
|
err = hsic.WriteFile(tlsCertPath, hsic.tlsCert)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to write TLS certificate to container: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = hsic.WriteFile(tlsKeyPath, hsic.tlsKey)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to write TLS key to container: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-02 02:55:48 -06:00
|
|
|
return hsic, nil
|
2022-10-13 08:01:23 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
func (t *HeadscaleInContainer) hasTLS() bool {
|
|
|
|
return len(t.tlsCert) != 0 && len(t.tlsKey) != 0
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
func (t *HeadscaleInContainer) Shutdown() error {
|
|
|
|
return t.pool.Purge(t.container)
|
|
|
|
}
|
|
|
|
|
2022-10-24 08:40:49 -06:00
|
|
|
func (t *HeadscaleInContainer) Execute(
|
|
|
|
command []string,
|
|
|
|
) (string, error) {
|
|
|
|
log.Println("command", command)
|
|
|
|
log.Printf("running command for %s\n", t.hostname)
|
|
|
|
stdout, stderr, err := dockertestutil.ExecuteCommand(
|
|
|
|
t.container,
|
|
|
|
command,
|
|
|
|
[]string{},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("command stderr: %s\n", stderr)
|
|
|
|
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
if stdout != "" {
|
|
|
|
log.Printf("command stdout: %s\n", stdout)
|
|
|
|
}
|
|
|
|
|
|
|
|
return stdout, nil
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
func (t *HeadscaleInContainer) GetIP() string {
|
|
|
|
return t.container.GetIPInNetwork(t.network)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) GetPort() string {
|
2022-11-03 17:05:01 -06:00
|
|
|
return fmt.Sprintf("%d", t.port)
|
2022-10-13 08:01:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) GetHealthEndpoint() string {
|
2022-11-06 12:22:21 -07:00
|
|
|
return fmt.Sprintf("%s/health", t.GetEndpoint())
|
2022-10-13 08:01:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) GetEndpoint() string {
|
2022-10-18 03:58:15 -06:00
|
|
|
hostEndpoint := fmt.Sprintf("%s:%d",
|
2022-10-13 08:01:23 -06:00
|
|
|
t.GetIP(),
|
2022-10-18 03:58:15 -06:00
|
|
|
t.port)
|
2022-10-13 08:01:23 -06:00
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
if t.hasTLS() {
|
|
|
|
return fmt.Sprintf("https://%s", hostEndpoint)
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
return fmt.Sprintf("http://%s", hostEndpoint)
|
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
func (t *HeadscaleInContainer) GetCert() []byte {
|
|
|
|
return t.tlsCert
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) GetHostname() string {
|
|
|
|
return t.hostname
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
func (t *HeadscaleInContainer) WaitForReady() error {
|
|
|
|
url := t.GetHealthEndpoint()
|
|
|
|
|
2022-10-18 03:58:15 -06:00
|
|
|
log.Printf("waiting for headscale to be ready at %s", url)
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
client := &http.Client{}
|
|
|
|
|
|
|
|
if t.hasTLS() {
|
2022-11-10 01:04:47 -07:00
|
|
|
insecureTransport := http.DefaultTransport.(*http.Transport).Clone() //nolint
|
|
|
|
insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint
|
2022-11-06 12:22:21 -07:00
|
|
|
client = &http.Client{Transport: insecureTransport}
|
|
|
|
}
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
return t.pool.Retry(func() error {
|
2022-11-06 12:22:21 -07:00
|
|
|
resp, err := client.Get(url) //nolint
|
2022-10-13 08:01:23 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
log.Printf("ready err: %s", err)
|
|
|
|
|
2022-10-13 08:01:23 -06:00
|
|
|
return fmt.Errorf("headscale is not ready: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
|
|
return errHeadscaleStatusCodeNotOk
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) CreateNamespace(
|
|
|
|
namespace string,
|
|
|
|
) error {
|
|
|
|
command := []string{"headscale", "namespaces", "create", namespace}
|
|
|
|
|
|
|
|
_, _, err := dockertestutil.ExecuteCommand(
|
|
|
|
t.container,
|
|
|
|
command,
|
|
|
|
[]string{},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) CreateAuthKey(
|
|
|
|
namespace string,
|
|
|
|
) (*v1.PreAuthKey, error) {
|
|
|
|
command := []string{
|
|
|
|
"headscale",
|
|
|
|
"--namespace",
|
|
|
|
namespace,
|
|
|
|
"preauthkeys",
|
|
|
|
"create",
|
|
|
|
"--reusable",
|
|
|
|
"--expiration",
|
|
|
|
"24h",
|
|
|
|
"--output",
|
|
|
|
"json",
|
|
|
|
}
|
|
|
|
|
|
|
|
result, _, err := dockertestutil.ExecuteCommand(
|
|
|
|
t.container,
|
|
|
|
command,
|
|
|
|
[]string{},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to execute create auth key command: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var preAuthKey v1.PreAuthKey
|
|
|
|
err = json.Unmarshal([]byte(result), &preAuthKey)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to unmarshal auth key: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &preAuthKey, nil
|
|
|
|
}
|
|
|
|
|
2022-10-23 04:41:35 -06:00
|
|
|
func (t *HeadscaleInContainer) ListMachinesInNamespace(
|
2022-10-13 08:01:23 -06:00
|
|
|
namespace string,
|
|
|
|
) ([]*v1.Machine, error) {
|
|
|
|
command := []string{"headscale", "--namespace", namespace, "nodes", "list", "--output", "json"}
|
|
|
|
|
|
|
|
result, _, err := dockertestutil.ExecuteCommand(
|
|
|
|
t.container,
|
|
|
|
command,
|
|
|
|
[]string{},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to execute list node command: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var nodes []*v1.Machine
|
|
|
|
err = json.Unmarshal([]byte(result), &nodes)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to unmarshal nodes: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodes, nil
|
|
|
|
}
|
2022-11-02 02:55:09 -06:00
|
|
|
|
|
|
|
func (t *HeadscaleInContainer) WriteFile(path string, data []byte) error {
|
2022-11-06 12:22:21 -07:00
|
|
|
return integrationutil.WriteFileToContainer(t.pool, t.container, path, data)
|
|
|
|
}
|
2022-11-02 02:55:09 -06:00
|
|
|
|
2022-11-10 01:02:40 -07:00
|
|
|
//nolint
|
2022-11-06 12:22:21 -07:00
|
|
|
func createCertificate() ([]byte, []byte, error) {
|
|
|
|
// From:
|
|
|
|
// https://shaneutt.com/blog/golang-ca-and-signed-cert-go/
|
2022-11-02 02:55:09 -06:00
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
ca := &x509.Certificate{
|
|
|
|
SerialNumber: big.NewInt(2019),
|
|
|
|
Subject: pkix.Name{
|
|
|
|
Organization: []string{"Headscale testing INC"},
|
|
|
|
Country: []string{"NL"},
|
|
|
|
Locality: []string{"Leiden"},
|
|
|
|
},
|
|
|
|
NotBefore: time.Now(),
|
|
|
|
NotAfter: time.Now().Add(30 * time.Minute),
|
|
|
|
IsCA: true,
|
|
|
|
ExtKeyUsage: []x509.ExtKeyUsage{
|
|
|
|
x509.ExtKeyUsageClientAuth,
|
|
|
|
x509.ExtKeyUsageServerAuth,
|
|
|
|
},
|
|
|
|
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
|
|
|
|
BasicConstraintsValid: true,
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
caPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)
|
2022-11-02 02:55:09 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
return nil, nil, err
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
cert := &x509.Certificate{
|
|
|
|
SerialNumber: big.NewInt(1658),
|
|
|
|
Subject: pkix.Name{
|
|
|
|
Organization: []string{"Headscale testing INC"},
|
|
|
|
Country: []string{"NL"},
|
|
|
|
Locality: []string{"Leiden"},
|
|
|
|
},
|
|
|
|
IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback},
|
|
|
|
NotBefore: time.Now(),
|
|
|
|
NotAfter: time.Now().Add(30 * time.Minute),
|
|
|
|
SubjectKeyId: []byte{1, 2, 3, 4, 6},
|
|
|
|
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth},
|
|
|
|
KeyUsage: x509.KeyUsageDigitalSignature,
|
|
|
|
}
|
|
|
|
|
|
|
|
certPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)
|
2022-11-02 02:55:09 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
return nil, nil, err
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
certBytes, err := x509.CreateCertificate(
|
|
|
|
rand.Reader,
|
|
|
|
cert,
|
|
|
|
ca,
|
|
|
|
&certPrivKey.PublicKey,
|
|
|
|
caPrivKey,
|
|
|
|
)
|
2022-11-02 02:55:09 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
return nil, nil, err
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
certPEM := new(bytes.Buffer)
|
2022-11-02 02:55:09 -06:00
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
err = pem.Encode(certPEM, &pem.Block{
|
|
|
|
Type: "CERTIFICATE",
|
|
|
|
Bytes: certBytes,
|
|
|
|
})
|
2022-11-02 02:55:09 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
return nil, nil, err
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
certPrivKeyPEM := new(bytes.Buffer)
|
|
|
|
|
|
|
|
err = pem.Encode(certPrivKeyPEM, &pem.Block{
|
|
|
|
Type: "RSA PRIVATE KEY",
|
|
|
|
Bytes: x509.MarshalPKCS1PrivateKey(certPrivKey),
|
|
|
|
})
|
2022-11-02 02:55:09 -06:00
|
|
|
if err != nil {
|
2022-11-06 12:22:21 -07:00
|
|
|
return nil, nil, err
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|
|
|
|
|
2022-11-06 12:22:21 -07:00
|
|
|
return certPEM.Bytes(), certPrivKeyPEM.Bytes(), nil
|
2022-11-02 02:55:09 -06:00
|
|
|
}
|