From f8f7fa1e4caf15a7fec6b0bb71aaaa41b3a7ee18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20D=C4=85browski?= Date: Fri, 7 Aug 2026 10:54:41 +0200 Subject: [PATCH] Insecureskipverify, cenrtificate --- internal/ccdb/requests.go | 12 +++++++++++- internal/ccdb/run_information.go | 5 +++-- internal/service/ccdb_service.go | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/ccdb/requests.go b/internal/ccdb/requests.go index 7cc66b3..7b8e556 100644 --- a/internal/ccdb/requests.go +++ b/internal/ccdb/requests.go @@ -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 }, diff --git a/internal/ccdb/run_information.go b/internal/ccdb/run_information.go index 5cae3ed..93c0b49 100644 --- a/internal/ccdb/run_information.go +++ b/internal/ccdb/run_information.go @@ -1,6 +1,7 @@ package ccdb import ( + "crypto/tls" "fmt" "strconv" ) @@ -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 } diff --git a/internal/service/ccdb_service.go b/internal/service/ccdb_service.go index 9bc4fb4..e53d935 100644 --- a/internal/service/ccdb_service.go +++ b/internal/service/ccdb_service.go @@ -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) }) }