Skip to content

Commit

Permalink
Add methods to get KeyPath and PemPath
Browse files Browse the repository at this point in the history
  • Loading branch information
free5gc-org committed Apr 9, 2022
1 parent 512a2ec commit 01d8c08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 0 additions & 2 deletions internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ package util

const (
NrfDefaultKeyLogPath = "./log/nrfsslkey.log"
NrfDefaultPemPath = "./config/TLS/nrf.pem"
NrfDefaultKeyPath = "./config/TLS/nrf.key"
NrfDefaultConfigPath = "./config/nrfcfg.yaml"
)
16 changes: 16 additions & 0 deletions pkg/factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
)

const (
NrfDefaultTLSPemPath = "./config/TLS/nrf.pem"
NrfDefaultTLSKeyPath = "./config/TLS/nrf.key"
NrfExpectedConfigVersion = "1.0.1"
NrfSbiDefaultIPv4 = "127.0.0.10"
NrfSbiDefaultPort = 8000
Expand Down Expand Up @@ -209,3 +211,17 @@ func (c *Config) GetSbiRegisterAddr() string {
func (c *Config) GetSbiUri() string {
return c.GetSbiScheme() + "://" + c.GetSbiRegisterAddr()
}

func (c *Config) TLSPemPath() string {
if c.Configuration.Sbi.Tls != nil {
return c.Configuration.Sbi.Tls.Pem
}
return NrfDefaultTLSPemPath
}

func (c *Config) TLSKeyPath() string {
if c.Configuration.Sbi.Tls != nil {
return c.Configuration.Sbi.Tls.Key
}
return NrfDefaultTLSKeyPath
}
12 changes: 3 additions & 9 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,6 @@ func (nrf *NRF) Start() {
discovery.AddService(router)
management.AddService(router)

pemPath := util.NrfDefaultPemPath
keyPath := util.NrfDefaultKeyPath
sbi := factory.NrfConfig.Configuration.Sbi
if sbi.Tls != nil {
pemPath = sbi.Tls.Pem
keyPath = sbi.Tls.Key
}

nrf_context.InitNrfContext()

signalChannel := make(chan os.Signal, 1)
Expand Down Expand Up @@ -182,7 +174,9 @@ func (nrf *NRF) Start() {
if serverScheme == "http" {
err = server.ListenAndServe()
} else if serverScheme == "https" {
err = server.ListenAndServeTLS(pemPath, keyPath)
err = server.ListenAndServeTLS(
factory.NrfConfig.TLSPemPath(),
factory.NrfConfig.TLSKeyPath())
}

if err != nil {
Expand Down

0 comments on commit 01d8c08

Please sign in to comment.