1*4724848cSchristos=pod 2*4724848cSchristos 3*4724848cSchristos=head1 NAME 4*4724848cSchristos 5*4724848cSchristosX509_chain_up_ref, 6*4724848cSchristosX509_new, X509_free, X509_up_ref - X509 certificate ASN1 allocation functions 7*4724848cSchristos 8*4724848cSchristos=head1 SYNOPSIS 9*4724848cSchristos 10*4724848cSchristos #include <openssl/x509.h> 11*4724848cSchristos 12*4724848cSchristos X509 *X509_new(void); 13*4724848cSchristos void X509_free(X509 *a); 14*4724848cSchristos int X509_up_ref(X509 *a); 15*4724848cSchristos STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *x); 16*4724848cSchristos 17*4724848cSchristos=head1 DESCRIPTION 18*4724848cSchristos 19*4724848cSchristosThe X509 ASN1 allocation routines, allocate and free an 20*4724848cSchristosX509 structure, which represents an X509 certificate. 21*4724848cSchristos 22*4724848cSchristosX509_new() allocates and initializes a X509 structure with reference count 23*4724848cSchristosB<1>. 24*4724848cSchristos 25*4724848cSchristosX509_free() decrements the reference count of B<X509> structure B<a> and 26*4724848cSchristosfrees it up if the reference count is zero. If B<a> is NULL nothing is done. 27*4724848cSchristos 28*4724848cSchristosX509_up_ref() increments the reference count of B<a>. 29*4724848cSchristos 30*4724848cSchristosX509_chain_up_ref() increases the reference count of all certificates in 31*4724848cSchristoschain B<x> and returns a copy of the stack. 32*4724848cSchristos 33*4724848cSchristos=head1 NOTES 34*4724848cSchristos 35*4724848cSchristosThe function X509_up_ref() if useful if a certificate structure is being 36*4724848cSchristosused by several different operations each of which will free it up after 37*4724848cSchristosuse: this avoids the need to duplicate the entire certificate structure. 38*4724848cSchristos 39*4724848cSchristosThe function X509_chain_up_ref() doesn't just up the reference count of 40*4724848cSchristoseach certificate it also returns a copy of the stack, using sk_X509_dup(), 41*4724848cSchristosbut it serves a similar purpose: the returned chain persists after the 42*4724848cSchristosoriginal has been freed. 43*4724848cSchristos 44*4724848cSchristos=head1 RETURN VALUES 45*4724848cSchristos 46*4724848cSchristosIf the allocation fails, X509_new() returns B<NULL> and sets an error 47*4724848cSchristoscode that can be obtained by L<ERR_get_error(3)>. 48*4724848cSchristosOtherwise it returns a pointer to the newly allocated structure. 49*4724848cSchristos 50*4724848cSchristosX509_up_ref() returns 1 for success and 0 for failure. 51*4724848cSchristos 52*4724848cSchristosX509_chain_up_ref() returns a copy of the stack or B<NULL> if an error 53*4724848cSchristosoccurred. 54*4724848cSchristos 55*4724848cSchristos=head1 SEE ALSO 56*4724848cSchristos 57*4724848cSchristosL<d2i_X509(3)>, 58*4724848cSchristosL<ERR_get_error(3)>, 59*4724848cSchristosL<X509_CRL_get0_by_serial(3)>, 60*4724848cSchristosL<X509_get0_signature(3)>, 61*4724848cSchristosL<X509_get_ext_d2i(3)>, 62*4724848cSchristosL<X509_get_extension_flags(3)>, 63*4724848cSchristosL<X509_get_pubkey(3)>, 64*4724848cSchristosL<X509_get_subject_name(3)>, 65*4724848cSchristosL<X509_get_version(3)>, 66*4724848cSchristosL<X509_NAME_add_entry_by_txt(3)>, 67*4724848cSchristosL<X509_NAME_ENTRY_get_object(3)>, 68*4724848cSchristosL<X509_NAME_get_index_by_NID(3)>, 69*4724848cSchristosL<X509_NAME_print_ex(3)>, 70*4724848cSchristosL<X509_sign(3)>, 71*4724848cSchristosL<X509V3_get_d2i(3)>, 72*4724848cSchristosL<X509_verify_cert(3)> 73*4724848cSchristos 74*4724848cSchristos=head1 COPYRIGHT 75*4724848cSchristos 76*4724848cSchristosCopyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. 77*4724848cSchristos 78*4724848cSchristosLicensed under the OpenSSL license (the "License"). You may not use 79*4724848cSchristosthis file except in compliance with the License. You can obtain a copy 80*4724848cSchristosin the file LICENSE in the source distribution or at 81*4724848cSchristosL<https://www.openssl.org/source/license.html>. 82*4724848cSchristos 83*4724848cSchristos=cut 84