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  christos X509_get_pubkey, X509_get0_pubkey, X509_set_pubkey, X509_get_X509_PUBKEY,
      6      1.1  christos X509_REQ_get_pubkey, X509_REQ_get0_pubkey, X509_REQ_set_pubkey,
      7      1.1  christos X509_REQ_get_X509_PUBKEY - get or set certificate or certificate request
      8      1.1  christos public key
      9      1.1  christos 
     10      1.1  christos =head1 SYNOPSIS
     11      1.1  christos 
     12      1.1  christos  #include <openssl/x509.h>
     13      1.1  christos 
     14      1.1  christos  EVP_PKEY *X509_get_pubkey(X509 *x);
     15      1.1  christos  EVP_PKEY *X509_get0_pubkey(const X509 *x);
     16      1.1  christos  int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
     17  1.1.1.2  christos  X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
     18      1.1  christos 
     19      1.1  christos  EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
     20      1.1  christos  EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);
     21      1.1  christos  int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
     22      1.1  christos  X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *x);
     23      1.1  christos 
     24      1.1  christos =head1 DESCRIPTION
     25      1.1  christos 
     26      1.1  christos X509_get_pubkey() attempts to decode the public key for certificate B<x>. If
     27      1.1  christos successful it returns the public key as an B<EVP_PKEY> pointer with its
     28      1.1  christos reference count incremented: this means the returned key must be freed up
     29      1.1  christos after use. X509_get0_pubkey() is similar except it does B<not> increment
     30      1.1  christos the reference count of the returned B<EVP_PKEY> so it must not be freed up
     31      1.1  christos after use.
     32      1.1  christos 
     33      1.1  christos X509_get_X509_PUBKEY() returns an internal pointer to the B<X509_PUBKEY>
     34      1.1  christos structure which encodes the certificate of B<x>. The returned value
     35      1.1  christos must not be freed up after use.
     36      1.1  christos 
     37      1.1  christos X509_set_pubkey() attempts to set the public key for certificate B<x> to
     38      1.1  christos B<pkey>. The key B<pkey> should be freed up after use.
     39      1.1  christos 
     40      1.1  christos X509_REQ_get_pubkey(), X509_REQ_get0_pubkey(), X509_REQ_set_pubkey() and
     41      1.1  christos X509_REQ_get_X509_PUBKEY() are similar but operate on certificate request B<req>.
     42      1.1  christos 
     43      1.1  christos =head1 NOTES
     44      1.1  christos 
     45      1.1  christos The first time a public key is decoded the B<EVP_PKEY> structure is
     46      1.1  christos cached in the certificate or certificate request itself. Subsequent calls
     47      1.1  christos return the cached structure with its reference count incremented to
     48      1.1  christos improve performance.
     49      1.1  christos 
     50      1.1  christos =head1 RETURN VALUES
     51      1.1  christos 
     52      1.1  christos X509_get_pubkey(), X509_get0_pubkey(), X509_get_X509_PUBKEY(),
     53      1.1  christos X509_REQ_get_pubkey() and X509_REQ_get_X509_PUBKEY() return a public key or
     54      1.1  christos B<NULL> if an error occurred.
     55      1.1  christos 
     56      1.1  christos X509_set_pubkey() and X509_REQ_set_pubkey() return 1 for success and 0
     57      1.1  christos for failure.
     58      1.1  christos 
     59      1.1  christos =head1 SEE ALSO
     60      1.1  christos 
     61      1.1  christos L<d2i_X509(3)>,
     62      1.1  christos L<ERR_get_error(3)>,
     63      1.1  christos L<X509_CRL_get0_by_serial(3)>,
     64      1.1  christos L<X509_get0_signature(3)>,
     65      1.1  christos L<X509_get_ext_d2i(3)>,
     66      1.1  christos L<X509_get_extension_flags(3)>,
     67      1.1  christos L<X509_get_subject_name(3)>,
     68      1.1  christos L<X509_get_version(3)>,
     69      1.1  christos L<X509_NAME_add_entry_by_txt(3)>,
     70      1.1  christos L<X509_NAME_ENTRY_get_object(3)>,
     71      1.1  christos L<X509_NAME_get_index_by_NID(3)>,
     72      1.1  christos L<X509_NAME_print_ex(3)>,
     73      1.1  christos L<X509_new(3)>,
     74      1.1  christos L<X509_sign(3)>,
     75      1.1  christos L<X509V3_get_d2i(3)>,
     76      1.1  christos L<X509_verify_cert(3)>
     77      1.1  christos 
     78      1.1  christos =head1 COPYRIGHT
     79      1.1  christos 
     80  1.1.1.2  christos Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
     81      1.1  christos 
     82  1.1.1.2  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     83      1.1  christos this file except in compliance with the License.  You can obtain a copy
     84      1.1  christos in the file LICENSE in the source distribution or at
     85      1.1  christos L<https://www.openssl.org/source/license.html>.
     86      1.1  christos 
     87      1.1  christos =cut
     88