X509_GET0_SIGNATURE(3ossl)
π X509_GET0_SIGNATURE(3ossl) π
okay bestie, buckle up, this is the X509_GET0_SIGNATURE(3ossl) page from the OpenSSL manual, and it's literally all about signature information. peek-a-boo into how certs sign themselves, iykyk. π¦
β¨ NAME β¨
So like, this one page is the group chat for a whole little squad of functions, and they're all about signature information:
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_ACERT_get0_signatureX509_ACERT_get0_info_sigalgX509_ACERT_get_signature_nidX509_get_signature_infoX509_SIG_INFO_getX509_SIG_INFO_set
πΈ 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);
int X509_get_signature_info(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);
π DESCRIPTION π
X509_get0_signature() sets *psig to the signature of x, and *palg to the signature algorithm of x. and bestie, listen β the values it hands back are internal pointers, which MUST NOT be freed up after the call. like, do NOT touch. hands off. π
X509_set0_signature() and X509_REQ_set1_signature_algo() are the equivalent setters for those two values that X509_get0_signature() gives you. (getters and setters, the iconic duo π
)
X509_get0_tbs_sigalg() returns the signature algorithm in the signed portion of x.
X509_get_signature_nid() returns the NID corresponding to the signature algorithm of x.
X509_REQ_get0_signature(), X509_REQ_get_signature_nid(), X509_CRL_get0_signature() and X509_CRL_get_signature_nid() do the exact same little routine for certificate requests and CRLs.
X509_ACERT_get0_signature(), X509_ACERT_get_signature_nid() and X509_ACERT_get0_info_sigalg() do the same thing again, but for attribute certificates. slay, equal treatment fr fr. β¨
X509_get_signature_info() retrieves information about the signature of certificate x. the NID of the signing digest gets written to *mdnid, the public key algorithm to *pknid, the effective security bits to *secbits, and flag details to *flags. any of these parameters can be NULL if you don't need that info β no pressure, bestie. π
X509_SIG_INFO_get() and X509_SIG_INFO_set() get and set information about a signature inside an X509_SIG_INFO structure. heads up though: they're only used by implementations of algorithms that need to set custom signature information. most applications will never need to call them. so if that's not you, you can literally keep scrolling. π§
π NOTES π
These functions give you lower level access to signatures in certificates β for when your app wants to analyse or generate a signature in a form where X509_sign() et al just isn't appropriate (say, a non standard or unsupported format). like when the standard route isn't giving. π
Now, important: the security bits returned by X509_get_signature_info() 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, because the signing key itself is less secure. example that lives in my head rent free: a certificate signed using SHA-512 and a 1024 bit RSA key. π
π«Ά 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 just fill in your pointers, bestie.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. null ALGO pointer). andX509_REQ_set0_signaturedoes not return an error value at all. iconic, no notes. β¨
π 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)
β HISTORY β
a little timeline of glow-ups, periodt:
- The
X509_get0_signature()andX509_get_signature_nid()functions were added in OpenSSL 1.0.2. - The
X509_REQ_get0_signature(),X509_REQ_get_signature_nid(),X509_CRL_get0_signature()andX509_CRL_get_signature_nid()were added in OpenSSL 1.1.0. - The
X509_REQ_set0_signature()andX509_REQ_set1_signature_algo()were added in OpenSSL 1.1.1e. - The
X509_ACERT_get0_signature(),X509_ACERT_get0_info_sigalg()andX509_ACERT_get_signature_nid()functions were added in OpenSSL 3.4.
π COPYRIGHT π
Copyright 2015-2024 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 whole page bestie, no cap. this was X509_GET0_SIGNATURE(3ossl) from OpenSSL 3.5.9, dated 2026-09-29. go forth and inspect those signatures, you absolute main character. π β¨π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms