Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aeon: load system CAs by default #1093

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- `tt aeon`: did not use system CAs by default.

## [2.7.0] - 2025-01-22

The release introduces an experimental support of console for AeonDB and
Expand Down
29 changes: 15 additions & 14 deletions cli/aeon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,29 @@ func getCertificate(args cmd.Ssl) (tls.Certificate, error) {
}

func getTlsConfig(args cmd.Ssl) (*tls.Config, error) {
if args.CaFile == "" {
return &tls.Config{
ClientAuth: tls.NoClientCert,
}, nil
}
var pool *x509.CertPool

ca, err := os.ReadFile(args.CaFile)
if err != nil {
return nil, fmt.Errorf("failed to read CA file: %w", err)
}
certPool := x509.NewCertPool()
if !certPool.AppendCertsFromPEM(ca) {
return nil, errors.New("failed to append CA data")
if args.CaFile != "" {
ca, err := os.ReadFile(args.CaFile)
if err != nil {
return nil, fmt.Errorf("failed to read CA file: %w", err)
}

pool = x509.NewCertPool()
if !pool.AppendCertsFromPEM(ca) {
return nil, errors.New("failed to append CA data")
}
}
// Else if RootCAs is nil, TLS uses the host's root CA set.

cert, err := getCertificate(args)
if err != nil {
return nil, fmt.Errorf("failed get certificate: %w", err)
}

return &tls.Config{
Certificates: []tls.Certificate{cert},
ClientAuth: tls.RequireAndVerifyClientCert,
RootCAs: certPool,
RootCAs: pool,
}, nil
}

Expand Down