Python Forum

Full Version: Delay in fetching kerberos tokens : python gssapi securitycontext
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
0
down vote
favorite

Hi I'm using a python function as follows for fetching kerberos tokens

def get_token(server):

    service = gssapi.Name("HTTP@%s" % server, gssapi.NameType.hostbased_service)

    ctx = gssapi.SecurityContext(name=service, usage="initiate")
    attempts = 0

    while True:
        try:
            print("before")

            token = ctx.step()

            print("after")  
            break
        except Exception as e:
            attempts += 1
            print(attempts)
            if attempts < MAX_TOKEN_ATTEMPTS:
                logger.debug("exception while getting Kerberos token, trying again", exc_info=e)
            else:
                raise OSError("too many failures while getting Kerberos token, discarding request") from e

    b64token = base64.b64encode(token)
    return b64token
The function is giving expected result. However the problem is, in one of my machine, the step "token = ctx.step()" is taking more than 5 sec to complete. In my other other machines it's taking less than 2 sec.

Any idea regrading the reason for delay?

-I have tried using IP address as well as the FQDN as the argument of the main funtion. all same.
-ping from all my machines to the server takes same time.

My environment:

Python 3.5.2
Ubuntu 16.04