Skip to content

Commit

Permalink
feat: parametrize paths for TLS certificate and private key (#128)
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Faccin <[email protected]>
Co-authored-by: Ajay Lotan Thakur <[email protected]>
  • Loading branch information
dariofaccin and thakurajayL authored Jul 20, 2024
1 parent 95f6589 commit 275ca2f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type PCFContext struct {
UriScheme models.UriScheme
BindingIPv4 string
RegisterIPv4 string
Key string
PEM string
TimeFormat string
DefaultBdtRefId string
NfService map[models.ServiceName]models.NfService
Expand Down
6 changes: 6 additions & 0 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ type Service struct {

type Sbi struct {
Scheme string `yaml:"scheme"`
TLS *TLS `yaml:"tls"`
RegisterIPv4 string `yaml:"registerIPv4,omitempty"` // IP that is registered at NRF.
// IPv6Addr string `yaml:"ipv6Addr,omitempty"`
BindingIPv4 string `yaml:"bindingIPv4,omitempty"` // IP used to run the server in the node.
Port int `yaml:"port,omitempty"`
}

type TLS struct {
PEM string `yaml:"pem,omitempty"`
Key string `yaml:"key,omitempty"`
}

type PlmnSupportItem struct {
PlmnId models.PlmnId `yaml:"plmnId"`
}
Expand Down
10 changes: 10 additions & 0 deletions util/init_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func InitpcfContext(context *context.PCFContext) {
context.UriScheme = ""
context.RegisterIPv4 = factory.PCF_DEFAULT_IPV4 // default localhost
context.SBIPort = factory.PCF_DEFAULT_PORT_INT // default port
context.Key = PCF_KEY_PATH // default key path
context.PEM = PCF_PEM_PATH // default PEM path
if sbi != nil {
if sbi.Scheme != "" {
context.UriScheme = models.UriScheme(sbi.Scheme)
Expand All @@ -47,6 +49,14 @@ func InitpcfContext(context *context.PCFContext) {
} else {
context.UriScheme = models.UriScheme_HTTP
}
if tls := sbi.TLS; tls != nil {
if tls.Key != "" {
context.Key = tls.Key
}
if tls.PEM != "" {
context.PEM = tls.PEM
}
}

context.BindingIPv4 = os.Getenv(sbi.BindingIPv4)
if context.BindingIPv4 != "" {
Expand Down

0 comments on commit 275ca2f

Please sign in to comment.