KRB5_GET_CREDS(3)
β¨ KRB5_GET_CREDS β¨
okay bestie, pull up a chair, because today we're reading a Library Functions Manual page and it's lowkey the most useful thing ever π it's all about grabbing credentials from the KDC, and there's a whole little family of functions here that work together like the friend group in a coming-of-age movie π«Ά
πΈ NAME πΈ
krb5_get_creds, krb5_get_creds_opt_add_options, krb5_get_creds_opt_alloc, krb5_get_creds_opt_free, krb5_get_creds_opt_set_enctype, krb5_get_creds_opt_set_impersonate, krb5_get_creds_opt_set_options, krb5_get_creds_opt_set_ticket β get credentials from the KDC π
π LIBRARY π
Kerberos 5 Library (libkrb5, -lkrb5) β link it or perish, no cap π
π SYNOPSIS π
#include <krb5.h>
krb5_error_code
krb5_get_creds(krb5_context context, krb5_get_creds_opt opt,
krb5_ccache ccache, krb5_const_principal inprinc,
krb5_creds **out_creds);
void
krb5_get_creds_opt_add_options(krb5_context context,
krb5_get_creds_opt opt, krb5_flags options);
krb5_error_code
krb5_get_creds_opt_alloc(krb5_context context, krb5_get_creds_opt *opt);
void
krb5_get_creds_opt_free(krb5_context context, krb5_get_creds_opt opt);
void
krb5_get_creds_opt_set_enctype(krb5_context context,
krb5_get_creds_opt opt, krb5_enctype enctype);
krb5_error_code
krb5_get_creds_opt_set_impersonate(krb5_context context,
krb5_get_creds_opt opt, krb5_const_principal self);
void
krb5_get_creds_opt_set_options(krb5_context context,
krb5_get_creds_opt opt, krb5_flags options);
krb5_error_code
krb5_get_creds_opt_set_ticket(krb5_context context,
krb5_get_creds_opt opt, const Ticket *ticket);
π DESCRIPTION π
okay so krb5_get_creds() is the main character here π
it fetches the credentials that opt is asking for β and the way it does that is so smart: first it peeks inside ccache, and if the credential isn't there (the page literally says "it doesn't exists", we don't make the rules, we just report them π), it goes and fetches that credential from the KDC using the krbtgts in ccache. The credential comes back to you in out_creds, and bestie β you have to free it with krb5_free_creds(). Don't ghost your memory, it's not the vibe π«Ά
The structure krb5_get_creds_opt is what controls the behavior of krb5_get_creds(). It's opaque to consumers β so you can't just reach in and touch it, you set what's inside using the accessor functions β¨ and here's the tea: all the accessor functions make copies of the data you pass in, so external consumers should free that memory before calling krb5_get_creds(). Clean up after yourself, queen π
The krb5_get_creds_opt structure gets allocated with krb5_get_creds_opt_alloc() and freed with krb5_get_creds_opt_free(). And the free function is an overachiever β it also frees the content of the structure that the accessor functions set. So thorough. So iconic π
krb5_get_creds_opt_add_options() and krb5_get_creds_opt_set_options() add and set options onto the krb5_get_creds_opt structure. (Yes, the original has a lil space before that period. We stan a quirky typo π)
The possible options you can set are:
KRB5_GC_CACHEDβ only check the ccache, don't go out on the network to fetch a credential. staying home era πKRB5_GC_USER_USERβ request a user to user ticket. and heads up: this option does not store the resulting user to user credential in the ccache π«KRB5_GC_EXPIRED_OKβ returns the credential even if it is expired. the default behavior is to try to refetch the credential from the KDC, so this one is the "nah, expired is fine, give it here" button β°KRB5_GC_NO_STOREβ do not store the resulting credentials in the ccache ποΈ
krb5_get_creds_opt_set_enctype() sets the preferred encryption type of the application. but listen β don't set this unless you have to, because if there's no match in the KDC, the function call will fail. it's giving "playing with fire" π₯
krb5_get_creds_opt_set_impersonate() sets the principal to impersonate. it returns a ticket that has the impersonation principal as a client and the requestor as the service. and note this carefully: the requested principal has to be the same as the client principal in the krbtgt. matching sets only, bestie π―
krb5_get_creds_opt_set_ticket() sets the extra ticket used in the user-to-user or contrained delegation use case. (yes it says "contrained" in the original and we are respectfully leaving it exactly as written π)
π¦ SEE ALSO π¦
krb5(3), krb5_get_credentials(3), krb5.conf(5) β go read these next, they're the extended universe π
and that's the whole page, bestie!! π this one shipped with the HEIMDAL source and is dated June 15, 2006 β a vintage classic that still ate, no crumbs left. go get those creds, you're gonna slay πβ¨π
π¦ where this page comes from
- alpine 3.22: heimdal-doc 7.8.0-r4 Β· BSD-3-Clause
- alpine 3.23: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- alpine 3.24: heimdal-doc 7.8.0-r5 Β· BSD-3-Clause
- debian bookworm: heimdal-dev 7.8.git20221117.28daf24+dfsg-2 Β· BSD-3-Clause
- debian trixie: heimdal-dev 7.8.git20221117.28daf24+dfsg-9+deb13u1 Β· BSD-3-Clause
- epel 10: heimdal-devel 7.8.0-26.el10_2 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- epel 9: heimdal-devel 7.8.0-5.el9 Β· BSD and MIT
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 43: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-26.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- fedora 44: heimdal-devel 7.8.0-28.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND HPND-export-US AND HPND-export2-US AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: heimdal 7.8.0-unstable-2024-09-10
- ubuntu jammy: heimdal-dev 7.7.0+dfsg-3ubuntu1 Β· BSD-3-Clause
- ubuntu noble: heimdal-dev 7.8.git20221117.28daf24+dfsg-5ubuntu3 Β· BSD-3-Clause
- ubuntu questing: heimdal-dev 7.8.git20221117.28daf24+dfsg-9ubuntu1
- ubuntu resolute: heimdal-dev 7.8.git20221117.28daf24+dfsg-11ubuntu1 Β· BSD-3-Clause
- ubuntu stonking: heimdal-dev 7.8.git20240113.1b4565a+dfsg-2ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2006 Kungliga Tekniska HΓΆgskolan
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms