Skip to content

Commit

Permalink
fix S3 TLS session (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq authored Nov 14, 2024
1 parent f894e8b commit b4d3084
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion internal/databases/sqlserver/backup_push_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func HandleBackupPush(dbnames []string, updateLatest, copyOnly bool) {
tracelog.InfoLogger.Printf("backup finished")
}

func backupSingleDatabase(ctx context.Context, db *sql.DB, backupName string, dbname string, builtinCompression, copyOnlyBackup bool) error {
func backupSingleDatabase(ctx context.Context, db *sql.DB, backupName string,
dbname string, builtinCompression, copyOnlyBackup bool) error {
baseURL := getDatabaseBackupURL(backupName, dbname)
size, blobCount, err := estimateDBSize(db, dbname)
if err != nil {
Expand Down
28 changes: 16 additions & 12 deletions pkg/storages/s3/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,28 @@ import (
)

func createSession(config *Config) (*session.Session, error) {
sess, err := session.NewSession()
if err != nil {
return nil, fmt.Errorf("init new default session: %w", err)
}

err = configureSession(sess, config)
if err != nil {
return nil, fmt.Errorf("configure session: %w", err)
}

sessOpts := session.Options{}
if config.CACertFile != "" {
file, err := os.Open(config.CACertFile)
if err != nil {
return nil, err
}
defer utility.LoggedClose(file, "S3 CA cert file")
sess, err = session.NewSessionWithOptions(session.Options{Config: *sess.Config, CustomCABundle: file})
return sess, err
sessOpts.CustomCABundle = file
}

if http.DefaultClient.Transport != nil {
http.DefaultClient.Transport = nil
}

sess, err := session.NewSessionWithOptions(sessOpts)
if err != nil {
return nil, fmt.Errorf("init new session: %w", err)
}

err = configureSession(sess, config)
if err != nil {
return nil, fmt.Errorf("configure session: %w", err)
}

if config.UseYCSessionToken != "" {
Expand Down

0 comments on commit b4d3084

Please sign in to comment.