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_version, X509_set_version, X509_REQ_get_version, X509_REQ_set_version, 6 1.1 christos X509_CRL_get_version, X509_CRL_set_version - get or set certificate, 7 1.1 christos certificate request or CRL version 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 long X509_get_version(const X509 *x); 14 1.1 christos int X509_set_version(X509 *x, long version); 15 1.1 christos 16 1.1 christos long X509_REQ_get_version(const X509_REQ *req); 17 1.1 christos int X509_REQ_set_version(X509_REQ *x, long version); 18 1.1 christos 19 1.1 christos long X509_CRL_get_version(const X509_CRL *crl); 20 1.1 christos int X509_CRL_set_version(X509_CRL *x, long version); 21 1.1 christos 22 1.1 christos =head1 DESCRIPTION 23 1.1 christos 24 1.1 christos X509_get_version() returns the numerical value of the version field of 25 1.1.1.2 christos certificate B<x>. These correspond to the constants B<X509_VERSION_1>, 26 1.1.1.2 christos B<X509_VERSION_2>, and B<X509_VERSION_3>. Note: the values of these constants 27 1.1.1.2 christos are defined by standards (X.509 et al) to be one less than the certificate 28 1.1.1.2 christos version. So B<X509_VERSION_3> has value 2 and B<X509_VERSION_1> has value 0. 29 1.1 christos 30 1.1 christos X509_set_version() sets the numerical value of the version field of certificate 31 1.1 christos B<x> to B<version>. 32 1.1 christos 33 1.1 christos Similarly X509_REQ_get_version(), X509_REQ_set_version(), 34 1.1 christos X509_CRL_get_version() and X509_CRL_set_version() get and set the version 35 1.1.1.2 christos number of certificate requests and CRLs. They use constants 36 1.1.1.2 christos B<X509_REQ_VERSION_1>, B<X509_CRL_VERSION_1>, and B<X509_CRL_VERSION_2>. 37 1.1 christos 38 1.1 christos =head1 NOTES 39 1.1 christos 40 1.1 christos The version field of certificates, certificate requests and CRLs has a 41 1.1 christos DEFAULT value of B<v1(0)> meaning the field should be omitted for version 42 1.1 christos 1. This is handled transparently by these functions. 43 1.1 christos 44 1.1 christos =head1 RETURN VALUES 45 1.1 christos 46 1.1 christos X509_get_version(), X509_REQ_get_version() and X509_CRL_get_version() 47 1.1 christos return the numerical value of the version field. 48 1.1 christos 49 1.1 christos X509_set_version(), X509_REQ_set_version() and X509_CRL_set_version() 50 1.1 christos return 1 for success and 0 for failure. 51 1.1 christos 52 1.1 christos =head1 SEE ALSO 53 1.1 christos 54 1.1 christos L<d2i_X509(3)>, 55 1.1 christos L<ERR_get_error(3)>, 56 1.1 christos L<X509_CRL_get0_by_serial(3)>, 57 1.1 christos L<X509_get0_signature(3)>, 58 1.1 christos L<X509_get_ext_d2i(3)>, 59 1.1 christos L<X509_get_extension_flags(3)>, 60 1.1 christos L<X509_get_pubkey(3)>, 61 1.1 christos L<X509_get_subject_name(3)>, 62 1.1 christos L<X509_NAME_add_entry_by_txt(3)>, 63 1.1 christos L<X509_NAME_ENTRY_get_object(3)>, 64 1.1 christos L<X509_NAME_get_index_by_NID(3)>, 65 1.1 christos L<X509_NAME_print_ex(3)>, 66 1.1 christos L<X509_new(3)>, 67 1.1 christos L<X509_sign(3)>, 68 1.1 christos L<X509V3_get_d2i(3)>, 69 1.1 christos L<X509_verify_cert(3)> 70 1.1 christos 71 1.1 christos =head1 HISTORY 72 1.1 christos 73 1.1 christos X509_get_version(), X509_REQ_get_version() and X509_CRL_get_version() are 74 1.1 christos functions in OpenSSL 1.1.0, in previous versions they were macros. 75 1.1 christos 76 1.1 christos =head1 COPYRIGHT 77 1.1 christos 78 1.1.1.2 christos Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. 79 1.1 christos 80 1.1.1.2 christos Licensed under the Apache License 2.0 (the "License"). You may not use 81 1.1 christos this file except in compliance with the License. You can obtain a copy 82 1.1 christos in the file LICENSE in the source distribution or at 83 1.1 christos L<https://www.openssl.org/source/license.html>. 84 1.1 christos 85 1.1 christos =cut 86