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