Skip to content

Commit

Permalink
feat: parametrize paths for TLS certificate and private key (#105)
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Faccin <[email protected]>
  • Loading branch information
dariofaccin authored Jul 19, 2024
1 parent 6e62f3c commit ac96c3f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type UDRContext struct {
Name string
UriScheme models.UriScheme
BindingIPv4 string
Key string
PEM string
RegisterIPv4 string // IP register to NRF
HttpIPv6Address string
NfId string
Expand Down
4 changes: 1 addition & 3 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ func (udr *UDR) Start() {
go metrics.InitMetrics()

udrLogPath := util.UdrLogPath
udrPemPath := util.UdrPemPath
udrKeyPath := util.UdrKeyPath

self := udr_context.UDR_Self()
util.InitUdrContext(self)
Expand Down Expand Up @@ -217,7 +215,7 @@ func (udr *UDR) Start() {
if serverScheme == "http" {
err = server.ListenAndServe()
} else if serverScheme == "https" {
err = server.ListenAndServeTLS(udrPemPath, udrKeyPath)
err = server.ListenAndServeTLS(self.PEM, self.Key)
}

if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions util/init_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func InitUdrContext(context *udr_context.UDRContext) {
context.NfId = uuid.New().String()
context.RegisterIPv4 = factory.UDR_DEFAULT_IPV4 // default localhost
context.SBIPort = factory.UDR_DEFAULT_PORT_INT // default port
context.Key = UdrKeyPath // default key path
context.PEM = UdrPemPath // default PEM path
if sbi := configuration.Sbi; sbi != nil {
context.UriScheme = models.UriScheme(sbi.Scheme)
if sbi.RegisterIPv4 != "" {
Expand All @@ -31,6 +33,14 @@ func InitUdrContext(context *udr_context.UDRContext) {
if sbi.Port != 0 {
context.SBIPort = sbi.Port
}
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 ac96c3f

Please sign in to comment.