Skip to content

Commit

Permalink
RHINENG-9505: use ca cert to access candlepin if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMraka committed Sep 11, 2024
1 parent 39798ae commit e447264
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type coreConfig struct {
CandlepinAddress string
CandlepinCert string
CandlepinKey string
CandlepinCA string
ManagerPrivateAddress string
ListenerPrivateAddress string
EvaluatorUploadPrivateAddress string
Expand Down Expand Up @@ -160,6 +161,7 @@ func initServicesFromEnv() {
CoreCfg.CandlepinAddress = Getenv("CANDLEPIN_ADDRESS", CoreCfg.CandlepinAddress)
CoreCfg.CandlepinCert = Getenv("CANDLEPIN_CERT", CoreCfg.CandlepinCert)
CoreCfg.CandlepinKey = Getenv("CANDLEPIN_KEY", CoreCfg.CandlepinKey)
CoreCfg.CandlepinCA = Getenv("CANDLEPIN_CA", CoreCfg.CandlepinCA)
}

func initDBFromClowder() {
Expand Down
7 changes: 7 additions & 0 deletions manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"app/base/utils"
"crypto/tls"
"crypto/x509"
"fmt"
"net/http"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -61,6 +62,12 @@ func CreateCandlepinClient() api.Client {
if err != nil {
return nil, err
}
if utils.CoreCfg.CandlepinCA != "" {
ok := certPool.AppendCertsFromPEM([]byte(utils.CoreCfg.CandlepinCA))
if !ok {
return nil, fmt.Errorf("could not parse candlepin ca cert")
}
}
tlsConfig = &tls.Config{
Certificates: []tls.Certificate{clientCert},
RootCAs: certPool,
Expand Down

0 comments on commit e447264

Please sign in to comment.