X509_NEW(3)
π X509_NEW(3) π β the X.509 certificate object, but make it make sense
okay so this is X509_NEW(3), your Library Functions Manual entry for the X.509 certificate object, and we're gonna keep every fact intact while making it cute. no cap π
πΈ NAME πΈ
X509_new, X509_dup, X509_REQ_to_X509, X509_free, X509_up_ref, X509_chain_up_ref β X.509 certificate object. that's the whole squad, bestie π«Ά
β¨ SYNOPSIS β¨
#include <openssl/x509.h>
X509 *
X509_new(void);
X509 *
X509_dup(X509 *a);
X509 *
X509_REQ_to_X509(X509_REQ *req, int days, EVP_PKEY *pkey);
void
X509_free(X509 *a);
int
X509_up_ref(X509 *a);
STACK_OF(X509) *
X509_chain_up_ref(STACK_OF(X509) *chain);
π DESCRIPTION π
X509_new()β allocates and initializes an emptyX509object with reference count1. it represents an ASN.1 Certificate structure defined in RFC 5280 section 4.1. it can hold a public key together with information about the person, organization, device, or function the associated private key belongs to. iconic little container, honestly πX509_dup()β creates a deep copy ofausingASN1_item_dup(3), setting the reference count of the copy to1. deep copy means deep copy, bestie π¦X509_REQ_to_X509()β allocates a new certificate object, copies the public key fromreqinto it, copies the subject name ofreqto both the subject and issuer names of the new certificate, sets thenotBeforefield to the current time and thenotAfterfield to the given number of days in the future, and signs the new certificate withX509_sign(3)usingpkeyand theMD5algorithm. ifreqcontains at least one attribute, the version of the new certificate is set to2. yes,MD5, that's literally what the page says π«X509_free()β decrements the reference count of theX509structureaand frees it up if the reference count reaches0. ifais aNULLpointer, no action occurs. polite and tidy β¨X509_up_ref()β increments the reference count ofaby1. this function is useful if a certificate structure is being used by several different operations each of which will free it up after use: this avoids the need to duplicate the entire certificate structure. sharing is caring, but with refcounts πX509_chain_up_ref()β performs a shallow copy of the givenchainusingsk_X509_dup()and increments the reference count of each contained certificate by1. its purpose is similar toX509_up_ref(): the returned chain persists after the original is freed. shallow copy, strong boundaries π§
π RETURN VALUES π
X509_new(),X509_dup(), andX509_REQ_to_X509()β return a pointer to the newly allocated object orNULLif an error occurs; an error code can be obtained byERR_get_error(3). bestie, check your errors πX509_up_ref()β returns1for success or0for failure.X509_chain_up_ref()β returns the copy of the chain orNULLif an error occurs.
π¦ SEE ALSO π¦
ASIdentifiers_new(3)ASRange_new(3)AUTHORITY_KEYID_new(3)BASIC_CONSTRAINTS_new(3)crypto(3)d2i_X509(3)IPAddressRange_new(3)PKCS8_PRIV_KEY_INFO_new(3)X509_ALGOR_new(3)X509_ATTRIBUTE_new(3)X509_check_ca(3)X509_check_host(3)X509_check_issued(3)X509_check_private_key(3)X509_check_purpose(3)X509_CINF_new(3)X509_cmp(3)X509_CRL_new(3)X509_digest(3)X509_EXTENSION_new(3)X509_find_by_subject(3)X509_get0_notBefore(3)X509_get0_signature(3)X509_get1_email(3)X509_get_ex_new_index(3)X509_get_extension_flags(3)X509_get_pubkey(3)X509_get_pubkey_parameters(3)X509_get_serialNumber(3)X509_get_subject_name(3)X509_get_version(3)X509_INFO_new(3)X509_load_cert_file(3)X509_LOOKUP_hash_dir(3)X509_LOOKUP_new(3)X509_NAME_new(3)X509_OBJECT_new(3)X509_PKEY_new(3)X509_print_ex(3)X509_PUBKEY_new(3)X509_PURPOSE_set(3)X509_REQ_new(3)X509_SIG_new(3)X509_sign(3)X509_STORE_CTX_new(3)X509_STORE_get_by_subject(3)X509_STORE_new(3)X509v3_addr_add_inherit(3)X509v3_addr_get_range(3)X509v3_addr_inherits(3)X509v3_addr_subset(3)X509v3_addr_validate_path(3)X509v3_asid_add_id_or_range(3)
β STANDARDS β
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile. periodt π
π HISTORY π
X509_new()andX509_free()appeared in SSLeay 0.4 or earlier.X509_dup()appeared in SSLeay 0.4.4.X509_REQ_to_X509()appeared in SSLeay 0.6.0.- These functions have been available since OpenBSD 2.4.
X509_up_ref()first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.1.X509_chain_up_ref()first appeared in OpenSSL 1.0.2 and has been available since OpenBSD 6.3.
ngl, that's a whole little timeline and it ate π°οΈβ¨
π BUGS π
The X.509 public key infrastructure and its data types contain too many design bugs to list them. for lots of examples, see the classic X.509 Style Guide: https://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt that Peter Gutmann published in 2000. not me exposing the lore, but there it is π
this X509_NEW(3) moment was brought to you by Debian, dated September 2, 2024 β now go forth and certify something, bestie π
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2016, 2018, 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2002, 2006, 2015, 2016 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms