Skip to content

Commit

Permalink
Fix TLS path (parametrize path for certificate and key) (#148)
Browse files Browse the repository at this point in the history
* Parametrize path(s) for TLS

Signed-off-by: Arrobo, Gabriel <[email protected]>

* Minor log fixing

Signed-off-by: Arrobo, Gabriel <[email protected]>

* Remove unused variable/comment

Signed-off-by: Arrobo, Gabriel <[email protected]>

* Create minor release

Signed-off-by: Arrobo, Gabriel <[email protected]>

* Try to simplify code

Signed-off-by: Arrobo, Gabriel <[email protected]>

---------

Signed-off-by: Arrobo, Gabriel <[email protected]>
  • Loading branch information
gab-arrobo authored Oct 29, 2024
1 parent 3883e57 commit 7b85f4d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3-dev
1.5.3
25 changes: 15 additions & 10 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ type PlmnSupportItem struct {

type Sbi struct {
Scheme string `yaml:"scheme"`
TLS *TLS `yaml:"tls"`
RegisterIPv4 string `yaml:"registerIPv4,omitempty"` // IP that is serviced or registered at another 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"`
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"`
}

var MinConfigAvailable bool
Expand Down Expand Up @@ -96,7 +101,7 @@ func (c *Config) GetSbiBindingAddr() string {
}
if c.Configuration.Sbi.BindingIPv4 != "" {
if bindIPv4 := os.Getenv(c.Configuration.Sbi.BindingIPv4); bindIPv4 != "" {
logger.CfgLog.Infof("Parsing ServerIPv4 [%s] from ENV Variable", bindIPv4)
logger.CfgLog.Infof("parsing ServerIPv4 [%s] from ENV Variable", bindIPv4)
bindAddr = bindIPv4 + ":"
} else {
bindAddr = c.Configuration.Sbi.BindingIPv4 + ":"
Expand Down Expand Up @@ -135,21 +140,21 @@ func (c *Config) GetSbiUri() string {

func (c *Config) UpdateConfig(commChannel chan *protos.NetworkSliceResponse) bool {
for rsp := range commChannel {
logger.GrpcLog.Infoln("Received updateConfig in the nrf app : ", rsp)
logger.GrpcLog.Infoln("received updateConfig in the nrf app: ", rsp)
for _, ns := range rsp.NetworkSlice {
logger.GrpcLog.Infoln("Network Slice Name ", ns.Name)
logger.GrpcLog.Infoln("Network Slice Name", ns.Name)
if ns.Site != nil {
logger.GrpcLog.Infoln("Network Slice has site name present ")
logger.GrpcLog.Infoln("Network Slice has site name present")
site := ns.Site
logger.GrpcLog.Infoln("Site name ", site.SiteName)
logger.GrpcLog.Infoln("Site name", site.SiteName)
if site.Plmn != nil {
logger.GrpcLog.Infoln("Plmn mcc ", site.Plmn.Mcc)
logger.GrpcLog.Infoln("Plmn mcc", site.Plmn.Mcc)
plmn := PlmnSupportItem{}
plmn.PlmnId.Mnc = site.Plmn.Mnc
plmn.PlmnId.Mcc = site.Plmn.Mcc
NrfConfig.Configuration.PlmnSupportList = append(NrfConfig.Configuration.PlmnSupportList, plmn)
} else {
logger.GrpcLog.Infoln("Plmn not present in the message ")
logger.GrpcLog.Infoln("Plmn not present in the message")
}

}
Expand Down
16 changes: 8 additions & 8 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ func (nrf *NRF) FilterCli(c *cli.Context) (args []string) {

func (nrf *NRF) Start() {
initLog.Infoln("server started")
dbadapter.ConnectToDBClient(factory.NrfConfig.Configuration.MongoDBName, factory.NrfConfig.Configuration.MongoDBUrl,
factory.NrfConfig.Configuration.MongoDBStreamEnable, factory.NrfConfig.Configuration.NfProfileExpiryEnable)
config := factory.NrfConfig.Configuration
dbadapter.ConnectToDBClient(config.MongoDBName, config.MongoDBUrl, config.MongoDBStreamEnable, config.NfProfileExpiryEnable)

router := utilLogger.NewGinWithZap(logger.GinLog)

Expand All @@ -243,26 +243,26 @@ func (nrf *NRF) Start() {
if os.Getenv("MANAGED_BY_CONFIG_POD") == "true" {
initLog.Infoln("MANAGED_BY_CONFIG_POD is true")
} else {
initLog.Infoln("Use helm chart config")
initLog.Infoln("use helm chart config")
}
bindAddr := factory.NrfConfig.GetSbiBindingAddr()
initLog.Infof("Binding addr: [%s]", bindAddr)
initLog.Infof("binding addr: [%s]", bindAddr)
server, err := http2_util.NewServer(bindAddr, util.NrfLogPath, router)

if server == nil {
initLog.Errorf("Initialize HTTP server failed: %+v", err)
initLog.Errorf("initialize HTTP server failed: %+v", err)
return
}

if err != nil {
initLog.Warnf("Initialize HTTP server: +%v", err)
initLog.Warnf("initialize HTTP server: +%v", err)
}

serverScheme := factory.NrfConfig.GetSbiScheme()
if serverScheme == "http" {
err = server.ListenAndServe()
} else if serverScheme == "https" {
err = server.ListenAndServeTLS(util.NrfPemPath, util.NrfKeyPath)
err = server.ListenAndServeTLS(config.Sbi.TLS.PEM, config.Sbi.TLS.Key)
}

if err != nil {
Expand Down Expand Up @@ -322,6 +322,6 @@ func (nrf *NRF) Exec(c *cli.Context) error {
}

func (nrf *NRF) Terminate() {
logger.InitLog.Infoln("terminating NRF...")
logger.InitLog.Infoln("terminating NRF")
logger.InitLog.Infoln("NRF terminated")
}

0 comments on commit 7b85f4d

Please sign in to comment.