Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: added ca to cli

=a8398a700920
diff --git a/cli/config/infisical-relay.yaml b/cli/config/infisical-relay.yaml
index 1a2f32d216..89c6b5e452 100644
--- a/cli/config/infisical-relay.yaml
+++ b/cli/config/infisical-relay.yaml
@@ -1,3 +1,8 @@
public_ip: 127.0.0.1
auth_secret: changeThisOnProduction
realm: infisical.org
+# set port 5349 for tls
+# port: 5349
+# tls_private_key_path: /full-path
+# tls_ca_path: /full-path
+# tls_cert_path: /full-path
diff --git a/cli/packages/gateway/relay.go b/cli/packages/gateway/relay.go
index 6659d14463..0db5fd387e 100644
--- a/cli/packages/gateway/relay.go
+++ b/cli/packages/gateway/relay.go
@@ -3,6 +3,7 @@ package gateway
import (
"context"
"crypto/tls"
+ "crypto/x509"
"errors"
"fmt"
"net"
@@ -37,8 +38,10 @@ type GatewayRelayConfig struct {
RelayMaxPort uint16 `yaml:"relay_max_port"`
TlsCertPath string `yaml:"tls_cert_path"`
TlsPrivateKeyPath string `yaml:"tls_private_key_path"`
+ TlsCaPath string `yaml:"tls_ca_path"`
tls tls.Certificate
+ tlsCa string
isTlsEnabled bool
}
@@ -79,19 +82,19 @@ func NewGatewayRelay(configFilePath string) (*GatewayRelay, error) {
return nil, errMissingTlsCert
}
- tlsCertFile, err := os.ReadFile(cfg.TlsCertPath)
+ cert, err := tls.LoadX509KeyPair(cfg.TlsCertPath, cfg.TlsPrivateKeyPath)
if err != nil {
- return nil, err
- }
- tlsPrivateKeyFile, err := os.ReadFile(cfg.TlsPrivateKeyPath)
- if err != nil {
- return nil, err
+ return nil, fmt.Errorf("Failed to read load server tls key pair: %w", err)
}
- cert, err := tls.LoadX509KeyPair(string(tlsCertFile), string(tlsPrivateKeyFile))
- if err != nil {
- return nil, err
+ if cfg.TlsCaPath != "" {
+ ca, err := os.ReadFile(cfg.TlsCaPath)
+ if err != nil {
+ return nil, fmt.Errorf("Failed to read tls ca: %w", err)
+ }
+ cfg.tlsCa = string(ca)
}
+
cfg.tls = cert
cfg.isTlsEnabled = true
}
@@ -140,8 +143,12 @@ func (g *GatewayRelay) Run() error {
}
if g.Config.isTlsEnabled {
+ caCertPool := x509.NewCertPool()
+ caCertPool.AppendCertsFromPEM([]byte(g.Config.tlsCa))
+
listenerConfigs[i].Listener = tls.NewListener(conn, &tls.Config{
Certificates: []tls.Certificate{g.Config.tls},
+ ClientCAs: caCertPool,
})
} else {
listenerConfigs[i].Listener = conn