Skip to content
Closed
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
12 changes: 11 additions & 1 deletion internal/ccdb/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ import (
)

// Inspired by retrieveHeaders method of O2 CcdbApi
func doRemoteHeaderCall(url, uniqueAgentID string, timestamp int64) (map[string]string, error) {
func doRemoteHeaderCall(url, uniqueAgentID string, timestamp int64, cert *tls.Certificate) (map[string]string, error) {
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
}
if cert != nil {
tlsConfig.Certificates = []tls.Certificate{*cert}
}

client := &http.Client{
Timeout: 10 * time.Second,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
Expand Down
5 changes: 3 additions & 2 deletions internal/ccdb/run_information.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ccdb

import (
"crypto/tls"
"fmt"
"strconv"
)
Expand All @@ -16,10 +17,10 @@ const (
AGENT string = "AliceTraINT_Agent/1.0"
)

func GetRunInformation(baseURL string, runNumber uint64) (*RunInformation, error) {
func GetRunInformation(baseURL string, runNumber uint64, cert *tls.Certificate) (*RunInformation, error) {
url := fmt.Sprintf("%s/%s/%d", baseURL, RCT_ENDPOINT, runNumber)

headers, err := doRemoteHeaderCall(url, AGENT, -1)
headers, err := doRemoteHeaderCall(url, AGENT, -1, cert)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/ccdb_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewCCDBService(env *environment.Env) *CCDBService {

func (s *CCDBService) GetRunInformation(runNumber uint64) (*ccdb.RunInformation, error) {
return applog.ExternalCallResult("CCDB", "GetRunInformation", fmt.Sprintf("run=%d", runNumber), func() (*ccdb.RunInformation, error) {
return ccdb.GetRunInformation(s.baseURL, runNumber)
return ccdb.GetRunInformation(s.baseURL, runNumber, &s.cert)
})
}

Expand Down
Loading