hx509_ca(3)
π hx509_ca β hx509 CA functions π
okay bestie, welcome to the CA corner of the Heimdal x509 library πΈ this is manual section 3, and no cap, this page is a whole moment β it's the certificate-authority toolkit, and we're gonna get through it together. grab a lil snack, we got this π
β¨ SYNOPSIS β¨
Functions
here's the whole squad, listed exactly how the page lists them, periodt π
Functions
int hx509_ca_tbs_init (hx509_context context, hx509_ca_tbs *tbs)
void hx509_ca_tbs_free (hx509_ca_tbs *tbs)
int hx509_ca_tbs_set_notBefore (hx509_context context, hx509_ca_tbs tbs,
time_t t)
int hx509_ca_tbs_set_notAfter (hx509_context context, hx509_ca_tbs tbs,
time_t t)
int hx509_ca_tbs_set_notAfter_lifetime (hx509_context context,
hx509_ca_tbs tbs, time_t delta)
const struct units * hx509_ca_tbs_template_units (void)
int hx509_ca_tbs_set_template (hx509_context context, hx509_ca_tbs tbs,
int flags, hx509_cert cert)
int hx509_ca_tbs_set_ca (hx509_context context, hx509_ca_tbs tbs, int
pathLenConstraint)
int hx509_ca_tbs_set_proxy (hx509_context context, hx509_ca_tbs tbs, int
pathLenConstraint)
int hx509_ca_tbs_set_domaincontroller (hx509_context context,
hx509_ca_tbs tbs)
int hx509_ca_tbs_set_spki (hx509_context context, hx509_ca_tbs tbs,
const SubjectPublicKeyInfo *spki)
int hx509_ca_tbs_set_serialnumber (hx509_context context, hx509_ca_tbs
tbs, const heim_integer *serialNumber)
int hx509_ca_tbs_add_eku (hx509_context context, hx509_ca_tbs tbs, const
heim_oid *oid)
int hx509_ca_tbs_add_crl_dp_uri (hx509_context context, hx509_ca_tbs
tbs, const char *uri, hx509_name issuername)
int hx509_ca_tbs_add_san_otherName (hx509_context context, hx509_ca_tbs
tbs, const heim_oid *oid, const heim_octet_string *os)
int hx509_ca_tbs_add_san_pkinit (hx509_context context, hx509_ca_tbs
tbs, const char *principal)
int hx509_ca_tbs_add_san_ms_upn (hx509_context context, hx509_ca_tbs
tbs, const char *principal)
int hx509_ca_tbs_add_san_jid (hx509_context context, hx509_ca_tbs tbs,
const char *jid)
int hx509_ca_tbs_add_san_hostname (hx509_context context, hx509_ca_tbs
tbs, const char *dnsname)
int hx509_ca_tbs_add_san_rfc822name (hx509_context context, hx509_ca_tbs
tbs, const char *rfc822Name)
int hx509_ca_tbs_set_subject (hx509_context context, hx509_ca_tbs tbs,
hx509_name subject)
int hx509_ca_tbs_set_unique (hx509_context context, hx509_ca_tbs tbs,
const heim_bit_string *subjectUniqueID, const heim_bit_string
*issuerUniqueID)
int hx509_ca_tbs_subject_expand (hx509_context context, hx509_ca_tbs
tbs, hx509_env env)
int hx509_ca_tbs_set_signature_algorithm (hx509_context context,
hx509_ca_tbs tbs, const AlgorithmIdentifier *sigalg)
int hx509_ca_sign (hx509_context context, hx509_ca_tbs tbs, hx509_cert
signer, hx509_cert *certificate)
int hx509_ca_sign_self (hx509_context context, hx509_ca_tbs tbs,
hx509_private_key signer, hx509_cert *certificate)
okay so vibe check on what you're looking at π almost every single one of these is a hx509_ca_tbs_* function, which is giving tbs = "to be signed" energy β you build up the certificate-to-be, tweak it, and then hand it off to be signed. the tbs ones are the build-up era, and the last two are the main-character moment where the signing actually happens π
a few things you'll spot in the crowd:
- the classic
hx509_context contextfirst argument, everywhere, like a lil signature perfume - the matching pair of
hx509_ca_tbs_initandhx509_ca_tbs_freeβ one opens the door, one closes it πͺβ¨ - the
add_san_*crew:otherName,pkinit,ms_upn,jid,hostname,rfc822nameβ all the subject alternative name flavors, each with its own lil type hx509_ca_tbs_template_unitsis the odd one out and honestly iconic for it β it takesvoidand hands you back aconst struct units *, no context arg, no tbs, just vibes π¦hx509_ca_signandhx509_ca_sign_selfβ the finale π one takes anhx509_cert signer, the other anhx509_private_key signer, and both hand you back anhx509_cert *certificate
heads up bestie: the names of these functions are not the whole story, and this page doesn't spill the details on them right here β the descriptions and examples live over in the Hx509 CA functions, so don't be out here guessing at behavior from a function name alone π
π«Ά Detailed Description π«Ά
See the Hx509 CA functions for description and examples.
that's it, that's the whole section, no crumbs left π and lowkey that's the whole point β this page is the index of the squad, and the actual lore drops in the CA functions doc. we're just getting started tho, so don't go anywhere π
π₯ FUNCTION DOCUMENTATION π₯
ok bestie, this is the part where we meet the actual functions π every single one of them, no skips, no cuts. buckle up π
hx509_ca_sign()
int hx509_ca_sign (hx509_context context, hx509_ca_tbs tbs,
hx509_cert signer, hx509_cert * certificate)
Signs a to-be-signed certificate object with an issuer certificate. like stamping your whole vibe with a CA seal of approval β¨
The caller needs to at least have called the following functions on the to-be-signed certificate object:
hx509_ca_tbs_init()hx509_ca_tbs_set_subject()hx509_ca_tbs_set_spki()
When done, the to-be-signed certificate object should be freed with hx509_ca_tbs_free(). π§Ή
When creating a self-signed certificate, use hx509_ca_sign_self() instead. not optional, bestie β different function for that π
Parameters
contextβ A hx509 context.tbsβ object to be signed.signerβ the CA certificate object to sign with (need private key). πcertificateβ return cerificate, free withhx509_cert_free().
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_sign_self()
int hx509_ca_sign_self (hx509_context context, hx509_ca_tbs tbs,
hx509_private_key signer, hx509_cert * certificate)
Works just like hx509_ca_sign() but signs it-self. main character energy, signing your own certificate π
β¨
Parameters
contextβ A hx509 context.tbsβ object to be signed.signerβ private key to sign with. πcertificateβ return cerificate, free withhx509_cert_free().
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_crl_dp_uri()
int hx509_ca_tbs_add_crl_dp_uri (hx509_context context, hx509_ca_tbs tbs,
const char * uri, hx509_name issuername)
Adds a CRL distribution point URI to the to-be-signed certificate object. π¦
Parameters
contextβ A hx509 context.tbsβ object to be signed.uriβ uri to the CRL.issuernameβ name of the issuer.
Returns
An hx509 error code, see hx509_get_error_string().
heads up bestie: issuername not supported π so don't go relying on that one.
hx509_ca_tbs_add_eku()
int hx509_ca_tbs_add_eku (hx509_context context, hx509_ca_tbs tbs,
const heim_oid * oid)
Adds an extended key usage to the to-be-signed certificate object. Duplicates will be detected and not added. so don't worry about accidentally double-dipping, it clocks it π
Parameters
contextβ A hx509 context.tbsβ object to be signed.oidβ extended key usage to add.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_hostname()
int hx509_ca_tbs_add_san_hostname (hx509_context context, hx509_ca_tbs tbs,
const char * dnsname)
Adds a Subject Alternative Name hostname to the to-be-signed certificate object. A domain match starts with ., an exact match does not. π
Example of a domain match: .domain.se matches the hostname host.domain.se. see the lil dot? that's the whole difference, iykyk β¨
Parameters
contextβ A hx509 context.tbsβ object to be signed.dnsnameβ a hostame.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_jid()
int hx509_ca_tbs_add_san_jid (hx509_context context, hx509_ca_tbs tbs,
const char * jid)
Adds a Jabber/XMPP jid Subject Alternative Name to the to-be-signed certificate object. The jid is an UTF8 string. π¬
Parameters
contextβ A hx509 context.tbsβ object to be signed.jidβ string of an a jabber id in UTF8.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_ms_upn()
int hx509_ca_tbs_add_san_ms_upn (hx509_context context, hx509_ca_tbs tbs,
const char * principal)
Adds a Microsoft UPN Subject Alternative Name to the to-be-signed certificate object. The principal string is a UTF8 string. πͺ
Parameters
contextβ A hx509 context.tbsβ object to be signed.principalβ Microsoft UPN string.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_otherName()
int hx509_ca_tbs_add_san_otherName (hx509_context context, hx509_ca_tbs tbs,
const heim_oid * oid, const heim_octet_string * os)
Adds a Subject Alternative Name otherName to the to-be-signed certificate object. π the catch-all slot fr fr
Parameters
contextβ A hx509 context.tbsβ object to be signed.oidβ the oid of the OtherName.osβ data in the other name.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_pkinit()
int hx509_ca_tbs_add_san_pkinit (hx509_context context, hx509_ca_tbs tbs,
const char * principal)
Adds a Kerberos Subject Alternative Name to the to-be-signed certificate object. The principal string is a UTF8 string. π
Parameters
contextβ A hx509 context.tbsβ object to be signed.principalβ Kerberos principal to add to the certificate.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_add_san_rfc822name()
int hx509_ca_tbs_add_san_rfc822name (hx509_context context, hx509_ca_tbs tbs,
const char * rfc822Name)
Adds a Subject Alternative Name rfc822 (email address) to the to-be-signed certificate object. π§ yes bestie, the certificate gets an email addy
Parameters
contextβ A hx509 context.tbsβ object to be signed.rfc822Nameβ a string to a email address.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_free()
void hx509_ca_tbs_free (hx509_ca_tbs * tbs)
Frees a To Be Signed object. clean up after yourself, bestie π§
Parameters
tbsβ object to free.
hx509_ca_tbs_init()
int hx509_ca_tbs_init (hx509_context context, hx509_ca_tbs * tbs)
Allocates a to-be-signed certificate object that will be converted into a certificate. this is the glow-up starting point β¨
Parameters
contextβ A hx509 context.tbsβ returned to-be-signed certicate object, free withhx509_ca_tbs_free().
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_ca()
int hx509_ca_tbs_set_ca (hx509_context context, hx509_ca_tbs tbs,
int pathLenConstraint)
Makes the to-be-signed certificate object a CA certificate. If the pathLenConstraint is negative, no path length constraint is used. π
Parameters
contextβ A hx509 context.tbsβ object to be signed.pathLenConstraintβ path length constraint, negative, no constraint.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_domaincontroller()
int hx509_ca_tbs_set_domaincontroller (hx509_context context,
hx509_ca_tbs tbs)
Makes the to-be-signed certificate object a windows domain controller certificate. πͺπ»
Parameters
contextβ A hx509 context.tbsβ object to be signed.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_notAfter()
int hx509_ca_tbs_set_notAfter (hx509_context context, hx509_ca_tbs tbs,
time_t t)
Sets the absolute time when the certificate is valid to. β° the expiry date, bestie, put it on your calendar
Parameters
contextβ A hx509 context.tbsβ object to be signed.tβ time when the certificate will expire
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_notAfter_lifetime()
int hx509_ca_tbs_set_notAfter_lifetime (hx509_context context,
hx509_ca_tbs tbs, time_t delta)
Sets the relative time when the certificiate is going to expire. β³ relative, not absolute β big difference bestie
Parameters
contextβ A hx509 context.tbsβ object to be signed.deltaβ seconds to the certificate is going to expire.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_notBefore()
int hx509_ca_tbs_set_notBefore (hx509_context context, hx509_ca_tbs tbs,
time_t t)
Sets the absolute time when the certificate is valid from. If not set, the current time will be used. π default is literally right now
Parameters
contextβ A hx509 context.tbsβ object to be signed.tβ time the certificated will start to be valid
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_proxy()
int hx509_ca_tbs_set_proxy (hx509_context context, hx509_ca_tbs tbs,
int pathLenConstraint)
Makes the to-be-signed certificate object a proxy certificate. If the pathLenConstraint is negative, no path length constraint is used. πΆοΈ
Parameters
contextβ A hx509 context.tbsβ object to be signed.pathLenConstraintβ path length constraint, negative, no constraint.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_serialnumber()
int hx509_ca_tbs_set_serialnumber (hx509_context context, hx509_ca_tbs tbs,
const heim_integer * serialNumber)
Sets the serial number to use for the to-be-signed certificate object. π’
Parameters
contextβ A hx509 context.tbsβ object to be signed.serialNumberβ serial number to use for the to-be-signed certificate object.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_signature_algorithm()
int hx509_ca_tbs_set_signature_algorithm (hx509_context context,
hx509_ca_tbs tbs, const AlgorithmIdentifier * sigalg)
Sets the signature algorithm on the to be signed certificate. βοΈ
Parameters
contextβ A hx509 context.tbsβ object to be signed.sigalgβ signature algorithm to use
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_spki()
int hx509_ca_tbs_set_spki (hx509_context context, hx509_ca_tbs tbs,
const SubjectPublicKeyInfo * spki)
Sets the subject public key info (SPKI) in the to-be-signed certificate object. SPKI is the public key and key related parameters in the certificate. πβ¨ the whole point of the cert honestly
Parameters
contextβ A hx509 context.tbsβ object to be signed.spkiβ subject public key info to use for the to-be-signed certificate object.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_subject()
int hx509_ca_tbs_set_subject (hx509_context context, hx509_ca_tbs tbs,
hx509_name subject)
Sets the subject name of a to-be-signed certificate object. π·οΈ who's this cert for, bestie
Parameters
contextβ A hx509 context.tbsβ object to be signed.subjectβ the name to set a subject.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_template()
int hx509_ca_tbs_set_template (hx509_context context, hx509_ca_tbs tbs,
int flags, hx509_cert cert)
Initializes the to-be-signed certificate object from a template certifiate. 𧬠copy-paste but make it cryptographic
Parameters
contextβ A hx509 context.tbsβ object to be signed.flagsβ bit field selecting what to copy from the template certifiate.certβ template certificate.
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_set_unique()
int hx509_ca_tbs_set_unique (hx509_context context, hx509_ca_tbs tbs,
const heim_bit_string * subjectUniqueID,
const heim_bit_string * issuerUniqueID)
Sets the issuerUniqueID and subjectUniqueID. π
These are only supposed to be used considered with version 2 certificates, replaced by the two extensions SubjectKeyIdentifier and IssuerKeyIdentifier. This function is to allow applications using legacy protocol to issue them.
fr fr read this one: these are legacy territory β the modern world moved on to SubjectKeyIdentifier and IssuerKeyIdentifier. this exists purely so apps speaking old protocols can still issue them. don't reach for it unless you actually have to π
Parameters
contextβ A hx509 context.tbsβ object to be signed.issuerUniqueIDβ to be setsubjectUniqueIDβ to be set
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_subject_expand()
int hx509_ca_tbs_subject_expand (hx509_context context, hx509_ca_tbs tbs,
hx509_env env)
Expands the the subject name in the to-be-signed certificate object using hx509_name_expand(). πΈ variable substitution, but for your DN
Parameters
contextβ A hx509 context.tbsβ object to be signed.envβ environment variable to expand variables in the subject name, seehx509_env_init().
Returns
An hx509 error code, see hx509_get_error_string().
hx509_ca_tbs_template_units()
const struct units* hx509_ca_tbs_template_units (void)
Make of template units, use to build the flags argument to hx509_ca_tbs_set_template() with parse_units(). π§©
Returns
an units structure.
π Author π
okay so bestie, plot twist: no human wrote this π
This whole page was generated automatically by Doxygen for the Heimdal x509 library, straight up pulled from the source code. So likeβ¦ nobody's out here taking credit for the prose, the computer just did its little thing and we love that for it. π€β¨
No cap, that means if something in here looks a lil quirky, it's because the source code said so, not because some author had main character energy. The docs and the code are basically holding hands fr fr. π«Ά
πΈ the sign-off πΈ
So this iconic lil manual page is hx509_ca(3), living in Version 7.8.0, and it was born way back on Tue Nov 15 2022 β a true vintage queen, honestly. π
That's the whole vibe, bestie. Go read the source, go call the functions, go 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
- 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms