Skip to content

Commit

Permalink
check for nil ctx in *RPCContext.Certificate
Browse files Browse the repository at this point in the history
Endpoints that are re-used are registered without a `ctx` object, so a
call to *RPCContext.Certificate could cause a panic if used in one of
these endpoints.
  • Loading branch information
lgfa29 committed Feb 2, 2022
1 parent c107cc1 commit 5d540a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nomad/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type RPCContext struct {

// Certificate returns the first certificate available in the chain.
func (ctx *RPCContext) Certificate() *x509.Certificate {
if len(ctx.VerifiedChains) == 0 || len(ctx.VerifiedChains[0]) == 0 {
if ctx == nil || len(ctx.VerifiedChains) == 0 || len(ctx.VerifiedChains[0]) == 0 {
return nil
}

Expand Down

0 comments on commit 5d540a4

Please sign in to comment.