diff --git a/context/context.go b/context/context.go index 62fb737..0fae25d 100644 --- a/context/context.go +++ b/context/context.go @@ -21,6 +21,7 @@ import ( "github.com/google/uuid" "github.com/omec-project/nssf/factory" "github.com/omec-project/nssf/logger" + "github.com/omec-project/nssf/util" "github.com/omec-project/openapi/models" ) @@ -53,6 +54,8 @@ type NSSFContext struct { UriScheme models.UriScheme RegisterIPv4 string BindingIPv4 string + Key string + PEM string NfService map[models.ServiceName]models.NfService NrfUri string SupportedPlmnList []models.PlmnId @@ -75,6 +78,16 @@ func InitNssfContext() { nssfContext.RegisterIPv4 = nssfConfig.Configuration.Sbi.RegisterIPv4 nssfContext.SBIPort = nssfConfig.Configuration.Sbi.Port nssfContext.BindingIPv4 = os.Getenv(nssfConfig.Configuration.Sbi.BindingIPv4) + nssfContext.Key = util.NSSF_KEY_PATH // default key path + nssfContext.PEM = util.NSSF_PEM_PATH // default PEM path + if tls := nssfConfig.Configuration.Sbi.TLS; tls != nil { + if tls.Key != "" { + nssfContext.Key = tls.Key + } + if tls.PEM != "" { + nssfContext.PEM = tls.PEM + } + } if nssfContext.BindingIPv4 != "" { logger.ContextLog.Info("Parsing ServerIPv4 address from ENV Variable.") } else { diff --git a/factory/config.go b/factory/config.go index 7e6d0d5..b7c9e9d 100644 --- a/factory/config.go +++ b/factory/config.go @@ -58,6 +58,7 @@ type Configuration struct { type Sbi struct { Scheme models.UriScheme `yaml:"scheme"` + TLS *TLS `yaml:"tls"` // Currently only support IPv4 and thus `Ipv4Addr` field shall not be empty RegisterIPv4 string `yaml:"registerIPv4,omitempty"` // IP that is registered at NRF. // IPv6Addr string `yaml:"ipv6Addr,omitempty"` @@ -65,6 +66,11 @@ type Sbi struct { Port int `yaml:"port"` } +type TLS struct { + PEM string `yaml:"pem,omitempty"` + Key string `yaml:"key,omitempty"` +} + type AmfConfig struct { NfId string `yaml:"nfId"` SupportedNssaiAvailabilityData []models.SupportedNssaiAvailabilityData `yaml:"supportedNssaiAvailabilityData"` diff --git a/service/init.go b/service/init.go index 085a4d7..2b70fa4 100644 --- a/service/init.go +++ b/service/init.go @@ -192,7 +192,7 @@ func (nssf *NSSF) Start() { if serverScheme == "http" { err = server.ListenAndServe() } else if serverScheme == "https" { - err = server.ListenAndServeTLS(util.NSSF_PEM_PATH, util.NSSF_KEY_PATH) + err = server.ListenAndServeTLS(self.PEM, self.Key) } if err != nil {