Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5  1.1.1.2  christos X509_new, X509_new_ex,
      6  1.1.1.2  christos X509_free, X509_up_ref,
      7  1.1.1.2  christos X509_chain_up_ref - X509 certificate ASN1 allocation functions
      8      1.1  christos 
      9      1.1  christos =head1 SYNOPSIS
     10      1.1  christos 
     11      1.1  christos  #include <openssl/x509.h>
     12      1.1  christos 
     13      1.1  christos  X509 *X509_new(void);
     14  1.1.1.2  christos  X509 *X509_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
     15      1.1  christos  void X509_free(X509 *a);
     16      1.1  christos  int X509_up_ref(X509 *a);
     17      1.1  christos  STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *x);
     18      1.1  christos 
     19      1.1  christos =head1 DESCRIPTION
     20      1.1  christos 
     21  1.1.1.3  christos The X509 ASN1 allocation routines allocate and free an
     22      1.1  christos X509 structure, which represents an X509 certificate.
     23      1.1  christos 
     24  1.1.1.2  christos X509_new_ex() allocates and initializes a X509 structure with a
     25  1.1.1.2  christos library context of I<libctx>, property query of I<propq> and a reference
     26  1.1.1.2  christos count of B<1>. Many X509 functions such as X509_check_purpose(), and
     27  1.1.1.2  christos X509_verify() use this library context to select which providers supply the
     28  1.1.1.2  christos fetched algorithms (SHA1 is used internally). This created X509 object can then
     29  1.1.1.2  christos be used when loading binary data using d2i_X509().
     30  1.1.1.2  christos 
     31  1.1.1.2  christos X509_new() is similar to X509_new_ex() but sets the library context
     32  1.1.1.2  christos and property query to NULL. This results in the default (NULL) library context
     33  1.1.1.2  christos being used for any X509 operations requiring algorithm fetches.
     34      1.1  christos 
     35      1.1  christos X509_free() decrements the reference count of B<X509> structure B<a> and
     36  1.1.1.3  christos frees it up if the reference count is zero. If the argument is NULL,
     37  1.1.1.3  christos nothing is done.
     38      1.1  christos 
     39      1.1  christos X509_up_ref() increments the reference count of B<a>.
     40      1.1  christos 
     41      1.1  christos X509_chain_up_ref() increases the reference count of all certificates in
     42  1.1.1.2  christos chain B<x> and returns a copy of the stack, or an empty stack if B<a> is NULL.
     43      1.1  christos 
     44      1.1  christos =head1 NOTES
     45      1.1  christos 
     46      1.1  christos The function X509_up_ref() if useful if a certificate structure is being
     47      1.1  christos used by several different operations each of which will free it up after
     48      1.1  christos use: this avoids the need to duplicate the entire certificate structure.
     49      1.1  christos 
     50      1.1  christos The function X509_chain_up_ref() doesn't just up the reference count of
     51  1.1.1.2  christos each certificate. It also returns a copy of the stack, using sk_X509_dup(),
     52      1.1  christos but it serves a similar purpose: the returned chain persists after the
     53      1.1  christos original has been freed.
     54      1.1  christos 
     55      1.1  christos =head1 RETURN VALUES
     56      1.1  christos 
     57  1.1.1.2  christos If the allocation fails, X509_new() returns NULL and sets an error
     58      1.1  christos code that can be obtained by L<ERR_get_error(3)>.
     59      1.1  christos Otherwise it returns a pointer to the newly allocated structure.
     60      1.1  christos 
     61      1.1  christos X509_up_ref() returns 1 for success and 0 for failure.
     62      1.1  christos 
     63  1.1.1.2  christos X509_chain_up_ref() returns a copy of the stack or NULL if an error occurred.
     64      1.1  christos 
     65      1.1  christos =head1 SEE ALSO
     66      1.1  christos 
     67      1.1  christos L<d2i_X509(3)>,
     68      1.1  christos L<ERR_get_error(3)>,
     69      1.1  christos L<X509_CRL_get0_by_serial(3)>,
     70      1.1  christos L<X509_get0_signature(3)>,
     71      1.1  christos L<X509_get_ext_d2i(3)>,
     72      1.1  christos L<X509_get_extension_flags(3)>,
     73      1.1  christos L<X509_get_pubkey(3)>,
     74      1.1  christos L<X509_get_subject_name(3)>,
     75      1.1  christos L<X509_get_version(3)>,
     76      1.1  christos L<X509_NAME_add_entry_by_txt(3)>,
     77      1.1  christos L<X509_NAME_ENTRY_get_object(3)>,
     78      1.1  christos L<X509_NAME_get_index_by_NID(3)>,
     79      1.1  christos L<X509_NAME_print_ex(3)>,
     80      1.1  christos L<X509_sign(3)>,
     81      1.1  christos L<X509V3_get_d2i(3)>,
     82      1.1  christos L<X509_verify_cert(3)>
     83      1.1  christos 
     84  1.1.1.2  christos =head1 HISTORY
     85  1.1.1.2  christos 
     86  1.1.1.2  christos The function X509_new_ex() was added in OpenSSL 3.0.
     87  1.1.1.2  christos 
     88      1.1  christos =head1 COPYRIGHT
     89      1.1  christos 
     90  1.1.1.3  christos Copyright 2002-2024 The OpenSSL Project Authors. All Rights Reserved.
     91      1.1  christos 
     92  1.1.1.2  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     93      1.1  christos this file except in compliance with the License.  You can obtain a copy
     94      1.1  christos in the file LICENSE in the source distribution or at
     95      1.1  christos L<https://www.openssl.org/source/license.html>.
     96      1.1  christos 
     97      1.1  christos =cut
     98