|
7 | 7 | "log/slog"
|
8 | 8 | "os"
|
9 | 9 | "os/signal"
|
10 |
| - "path/filepath" |
11 | 10 | "strings"
|
12 | 11 | "syscall"
|
13 | 12 |
|
@@ -155,21 +154,13 @@ func Run(config Config, args []string) error {
|
155 | 154 | logger.Error("Failed to create certificate manager", "error", err)
|
156 | 155 | return fmt.Errorf("failed to create certificate manager: %v", err)
|
157 | 156 | }
|
158 |
| - tlsConfig = certManager.GetTLSConfig() |
159 | 157 |
|
160 |
| - // Get CA certificate for environment |
161 |
| - caCertPEM, err := certManager.GetCACertPEM() |
| 158 | + // Setup TLS config and write CA certificate to file |
| 159 | + var caCertPath string |
| 160 | + tlsConfig, caCertPath, _, err = certManager.SetupTLSAndWriteCACert() |
162 | 161 | if err != nil {
|
163 |
| - logger.Error("Failed to get CA certificate", "error", err) |
164 |
| - return fmt.Errorf("failed to get CA certificate: %v", err) |
165 |
| - } |
166 |
| - |
167 |
| - // Write CA certificate to a temporary file for tools that need a file path |
168 |
| - caCertPath := filepath.Join(configDir, "ca-cert.pem") |
169 |
| - err = os.WriteFile(caCertPath, caCertPEM, 0644) |
170 |
| - if err != nil { |
171 |
| - logger.Error("Failed to write CA certificate file", "error", err) |
172 |
| - return fmt.Errorf("failed to write CA certificate file: %v", err) |
| 162 | + logger.Error("Failed to setup TLS and CA certificate", "error", err) |
| 163 | + return fmt.Errorf("failed to setup TLS and CA certificate: %v", err) |
173 | 164 | }
|
174 | 165 |
|
175 | 166 | // Set standard CA certificate environment variables for common tools
|
|
0 commit comments