Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use expiry from negotiated context #121

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions gss/apcera.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,10 @@ func (c *Client) NegotiateContext(host string) (keyname string, expiry time.Time
var (
input *gssapi.Buffer
ctx *gssapi.CtxId
tkey *dns.TKEY
)

for ok := true; ok; ok = c.lib.LastStatus.Major.ContinueNeeded() {
nctx, _, output, _, _, err := c.lib.InitSecContext(
nctx, _, output, _, duration, err := c.lib.InitSecContext(
c.lib.GSS_C_NO_CREDENTIAL,
ctx, // nil initially
service,
Expand All @@ -174,7 +173,7 @@ func (c *Client) NegotiateContext(host string) (keyname string, expiry time.Time
c.lib.GSS_C_NO_CHANNEL_BINDINGS,
input)

ctx = nctx
ctx, expiry = nctx, time.Now().UTC().Add(duration)

defer func() {
err = multierror.Append(err, output.Release()).ErrorOrNil()
Expand All @@ -190,7 +189,8 @@ func (c *Client) NegotiateContext(host string) (keyname string, expiry time.Time
}

//nolint:lll
if tkey, _, err = util.ExchangeTKEY(c.client, host, keyname, tsig.GSS, util.TkeyModeGSS, 3600, output.Bytes(), nil, "", ""); err != nil {
tkey, _, err := util.ExchangeTKEY(c.client, host, keyname, tsig.GSS, util.TkeyModeGSS, 3600, output.Bytes(), nil, "", "")
if err != nil {
return "", time.Time{}, multierror.Append(err, ctx.DeleteSecContext())
}

Expand All @@ -212,8 +212,6 @@ func (c *Client) NegotiateContext(host string) (keyname string, expiry time.Time
}()
}

expiry = time.Unix(int64(tkey.Expiration), 0)

c.m.Lock()
defer c.m.Unlock()

Expand Down
4 changes: 1 addition & 3 deletions gss/gokrb5.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,12 @@ func (c *Client) negotiateContext(host string, options []wrapper.Option[wrapper.
}
}

expiry := time.Unix(int64(tkey.Expiration), 0)

c.m.Lock()
defer c.m.Unlock()

c.ctx[keyname] = ctx

return keyname, expiry, nil
return keyname, ctx.Expiry(), nil
}

// NegotiateContext exchanges RFC 2930 TKEY records with the indicated DNS
Expand Down
4 changes: 1 addition & 3 deletions gss/sspi.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ func (c *Client) negotiateContext(host string, creds *sspi.Credentials) (string,
}
}

expiry := time.Unix(int64(tkey.Expiration), 0)

c.m.Lock()
defer c.m.Unlock()

c.ctx[keyname] = ctx

return keyname, expiry, nil
return keyname, ctx.Expiry(), nil
}

// NegotiateContext exchanges RFC 2930 TKEY records with the indicated DNS
Expand Down