feat: Fully featured Go client for the secrets service.

This commit is contained in:
jmug committed 2026-10-24 01:38:05 -07:00
1 parent 7b715da87f
commit 39ea9d708a
2 files changed
+187

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package secretsclient
import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net/http"
"os"
"time"
)
func newMTLSClient(ca, cert, key string) (*http.Client, error) {
caPEMBytes, err := os.ReadFile(ca)
if err != nil {
return nil, err
}
caPool := x509.NewCertPool()
if !caPool.AppendCertsFromPEM(caPEMBytes) {
return nil, errors.New("could create a ca pool from file")
}
cliCert, err := tls.LoadX509KeyPair(cert, key)
if err != nil {
return nil, fmt.Errorf("could not load client cert/key: %w", err)
}
return &http.Client{
// TODO: Tune other params.
Timeout: 10 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: caPool,
Certificates: []tls.Certificate{cliCert},
},
},
}, nil
}