X509_GET0_SIGNATURE(3SSL)
β¨ X509_GET0_SIGNATURE β¨
okay bestie, gather round, because today we're talking about signature information β all the little receipts a certificate carries about how it got signed π
this is the OpenSSL family of functions that peek at, set, and generally vibe check the signature bits inside X509 certs, cert requests, CRLs and attribute certs. she does a lot. she's booked and busy. π
Meet the cast, because there's like fifteen of them and they all show up to the function party:
X509_get0_signatureX509_REQ_set0_signatureX509_REQ_set1_signature_algoX509_get_signature_nidX509_get0_tbs_sigalgX509_REQ_get0_signatureX509_REQ_get_signature_nidX509_CRL_get0_signatureX509_CRL_get_signature_nidX509_CRL_get0_tbs_sigalgX509_get_signature_infoX509_SIG_INFO_getX509_SIG_INFO_setX509_ACERT_get0_signatureX509_ACERT_get0_info_sigalgX509_ACERT_get_signature_nid
group chat name: signature information π¦
π SYNOPSIS π
#include <openssl/x509.h>
void X509_get0_signature(const ASN1_BIT_STRING **psig,
const X509_ALGOR **palg,
const X509 *x);
void X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig);
int X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg);
int X509_get_signature_nid(const X509 *x);
const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
void X509_REQ_get0_signature(const X509_REQ *crl,
const ASN1_BIT_STRING **psig,
const X509_ALGOR **palg);
int X509_REQ_get_signature_nid(const X509_REQ *crl);
const X509_ALGOR *X509_ACERT_get0_info_sigalg(const X509_ACERT *x);
void X509_CRL_get0_signature(const X509_CRL *crl,
const ASN1_BIT_STRING **psig,
const X509_ALGOR **palg);
int X509_CRL_get_signature_nid(const X509_CRL *crl);
const X509_ALGOR *X509_CRL_get0_tbs_sigalg(const X509_crl *crl);
int X509_get_signature_info(const X509 *x, int *mdnid, int *pknid, int *secbits,
uint32_t *flags);
int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,
int *secbits, uint32_t *flags);
void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,
int secbits, uint32_t flags);
#include <openssl/x509_acert.h>
void X509_ACERT_get0_signature(const X509_ACERT *x,
const ASN1_BIT_STRING **psig,
const X509_ALGOR **palg);
int X509_ACERT_get_signature_nid(const X509_ACERT *x);
=head1 DESCRIPTION
(yes that last line is literally in the original, i'm not making it up, we keep the artifacts bestie π)
πΈ DESCRIPTION πΈ
X509_get0_signature() is the icon herself: she sets *psig to the signature of x, and *palg to the signature algorithm of x. BIG WARNING THOUGH β the values she hands back are internal pointers, and they MUST NOT be freed up after the call. do not. i am begging. put the free() down. π«Ά
X509_set0_signature() and X509_REQ_set1_signature_algo() are the equivalent setters for those two values that X509_get0_signature() gives you. matching set, slay.
X509_get0_tbs_sigalg() and X509_CRL_get0_tbs_sigalg() return the signature algorithm that lives in the signed portion of the certificate or CRL. the signed part. the part that's actually protected. iykyk.
X509_get_signature_nid() returns the NID corresponding to the signature algorithm of x. one NID, that's it, that's the whole job. π
X509_REQ_get0_signature(), X509_REQ_get_signature_nid(), X509_CRL_get0_signature() and X509_CRL_get_signature_nid() do the exact same little dance, but for certificate requests and CRLs. same energy, different object.
X509_get_signature_info() pulls up the full dossier on certificate x's signature:
- the NID of the signing digest goes to
*mdnidπ - the public key algorithm goes to
*pknidπ - the effective security bits go to
*secbitsπ - the flag details go to
*flagsπ©
and the best part? you can set <highlight>any</highlight> of those parameters to NULL if you don't need that info. no pressure, no forced commitments, we love a low-maintenance API π
X509_SIG_INFO_get() and X509_SIG_INFO_set() get and set information about a signature inside an X509_SIG_INFO structure. real talk though: these two are only used by implementations of algorithms that need to set custom signature information. like, most applications will literally never need to call them. if you're calling them, you already know why. main character behavior, but a niche one. β¨
X509_ACERT_get0_signature(), X509_ACERT_get_signature_nid() and X509_ACERT_get0_info_sigalg() do the same thing again for attribute certificates. trio behavior π
π₯ NOTES π₯
These functions give you lower level access to signatures in certificates. when do you want that? when your application wants to analyse or generate a signature in a form where X509_sign() et al is not appropriate β for example a non standard or unsupported format. Yeah. Sometimes the normal path just doesn't fit and you gotta go direct. it's giving DIY. π§
And here's the part that matters, bestie, listen up: the security bits that X509_get_signature_info() returns refer to information available from the certificate signature β stuff like the signing digest. But in some cases the actual security of the signature is less than that, because the signing key itself is less secure.
The example. Remember the example. A certificate signed using SHA-512 and a 1024 bit RSA key. digest looking snatched, key looking... not. π the numbers lie to you sometimes.
π RETURN VALUES π
X509_get_signature_nid(),X509_REQ_get_signature_nid()andX509_CRL_get_signature_nid()β return a NID βX509_get0_signature(),X509_REQ_get0_signature()andX509_CRL_get0_signature()β do not return values. they're void. they hand you stuff through pointers. silent but powerful. πX509_get_signature_info()β returns1if the signature information returned is valid, or0if the information is not available (e.g. unknown algorithms or malformed parameters). πX509_REQ_set1_signature_algo()β returns0on success; or1on an error (e.g. nullALGOpointer). yes bestie you read that right, it's inverted, that's just how she is, that's the API's whole brand.0good,1bad, no cap. πX509_REQ_set0_signatureβ does not return an error value. she simply does not report back. π
π SEE ALSO π
d2i_X509(3), ERR_get_error(3), X509_CRL_get0_by_serial(3), X509_get_ext_d2i(3), X509_get_extension_flags(3), X509_get_pubkey(3), X509_get_subject_name(3), X509_get_version(3), X509_NAME_add_entry_by_txt(3), X509_NAME_ENTRY_get_object(3), X509_NAME_get_index_by_NID(3), X509_NAME_print_ex(3), X509_new(3), X509_sign(3), X509V3_get_d2i(3), X509_verify_cert(3)
the whole friend group π go read them, they're all lore-relevant.
π¦ HISTORY π¦
a lil timeline, because this API's been growing:
X509_get0_signature()andX509_get_signature_nid()β added in OpenSSL 1.0.2 πΌX509_REQ_get0_signature(),X509_REQ_get_signature_nid(),X509_CRL_get0_signature()andX509_CRL_get_signature_nid()β added in OpenSSL 1.1.0X509_REQ_set0_signature()andX509_REQ_set1_signature_algo()β added in OpenSSL 1.1.1eX509_ACERT_get0_signature(),X509_ACERT_get0_info_sigalg()andX509_ACERT_get_signature_nid()β added in OpenSSL 3.4 β¨ (fresh drop)X509_CRL_get0_tbs_sigalg()β added in OpenSSL 3.6 π (newest baby in the lineup)
glow ups across the decades, we love to see it.
π COPYRIGHT π
Copyright <highlight>2015-2026</highlight> The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
and that's the page, bestie!! π stay safe out there, don't free the internal pointers, respect the inverted return codes, and remember that a SHA-512 digest on a weak key is just vibes. this was page X509_GET0_SIGNATURE(3SSL) from the OpenSSL fam, version 4.0.3, dated 2026-09-29. periodt. π
β¨π«Ά
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms