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

TGT renewal doesn't work when using Krb5TicketCache #285

Open
macsux opened this issue Feb 2, 2022 · 4 comments
Open

TGT renewal doesn't work when using Krb5TicketCache #285

macsux opened this issue Feb 2, 2022 · 4 comments
Labels

Comments

@macsux
Copy link
Contributor

macsux commented Feb 2, 2022

Describe the bug
KerberosClient has a feature to refresh expiring TGTs, but this seems to work only for MemoryTicketCache. When using Krb5TicketCache TGT is not getting refreshed.

To Reproduce
Switch cache to Krb5TicketCache

Expected behavior
TGT gets refreshed regardless of ticket cache being used

@macsux macsux added the bug label Feb 2, 2022
@SteveSyfuhs
Copy link
Collaborator

Fixed with #286. An updated nuget package will be available within a few minutes. Please verify when you get a chance. :)

@macsux
Copy link
Contributor Author

macsux commented Feb 23, 2022

So now I'm getting this after a while....

   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT       Kerberos.NET.KerberosProtocolException: KDC KRB_AP_ERR_TKT_EXPIRED: Ticket expired
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Kerberos.NET.Transport.KerberosTransportBase.Decode[T](ReadOnlyMemory`1 response) in D:\a\1\s\Kerberos.NET\Client\Transport\KerberosTransportBase.cs:line 70
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Kerberos.NET.Transport.TcpKerberosTransport.ReadResponse[T](NetworkStream stream, CancellationToken cancellation, TimeSpan readTimeout) in D:\a\1\s\Kerberos.NET\Client\Transport\TcpKerberosTransport.cs:line 133
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Kerberos.NET.Transport.TcpKerberosTransport.SendMessage[T](String domain, ReadOnlyMemory`1 encoded, CancellationToken cancellation)
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Kerberos.NET.Transport.KerberosTransportSelector.SendMessage[T](String domain, ReadOnlyMemory`1 encoded, CancellationToken cancellation)
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Kerberos.NET.Client.KerberosClient.RenewTicket(String spn) in D:\a\1\s\Kerberos.NET\Client\KerberosClient.cs:line 1078
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at KerberosSidecar.KerberosWorker.RefreshTicketIfExpiring() in C:\projects\KerberosBuildpack\src\KerberosSidecar\KerberosWorker.cs:line 152
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at KerberosSidecar.KerberosWorker.ExecuteAsync(CancellationToken stoppingToken) in C:\projects\KerberosBuildpack\src\KerberosSidecar\KerberosWorker.cs:line 139
   2022-02-18T16:35:21.10-0500 [APP/PROC/WEB/0] OUT          at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)

Here's where it's called from. I know explicit refresh like I'm doing here should technically not be needed anymore, but it should still work shouldn't it?

https://github.com/macsux/kerberos-buildpack/blob/3e71840e578c48d6cb17789ab520aa138b751546/src/KerberosSidecar/KerberosWorker.cs#L144

Code is running on 4.5.155

@SteveSyfuhs
Copy link
Collaborator

Your logic isn't quite right. The cache as you're querying it will return any ticket expired or not. As such you can absolutely have a TGT in the cache that is past its expiration, but before it's renewtill date. If you're going to be doing something like that then you need to check tgt.EndTime < DateTimeOffset.UtcNow.

@macsux
Copy link
Contributor Author

macsux commented Feb 24, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants