Blame doc/man3/X509_get_extension_flags.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
X509_get0_subject_key_id,
Packit c4476c
X509_get0_authority_key_id,
Packit c4476c
X509_get0_authority_issuer,
Packit c4476c
X509_get0_authority_serial,
Packit c4476c
X509_get_pathlen,
Packit c4476c
X509_get_extension_flags,
Packit c4476c
X509_get_key_usage,
Packit c4476c
X509_get_extended_key_usage,
Packit c4476c
X509_set_proxy_flag,
Packit c4476c
X509_set_proxy_pathlen,
Packit c4476c
X509_get_proxy_pathlen - retrieve certificate extension data
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/x509v3.h>
Packit c4476c
Packit c4476c
 long X509_get_pathlen(X509 *x);
Packit c4476c
 uint32_t X509_get_extension_flags(X509 *x);
Packit c4476c
 uint32_t X509_get_key_usage(X509 *x);
Packit c4476c
 uint32_t X509_get_extended_key_usage(X509 *x);
Packit c4476c
 const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);
Packit c4476c
 const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x);
Packit c4476c
 const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x);
Packit c4476c
 const ASN1_INTEGER *X509_get0_authority_serial(X509 *x);
Packit c4476c
 void X509_set_proxy_flag(X509 *x);
Packit c4476c
 void X509_set_proxy_pathlen(int l);
Packit c4476c
 long X509_get_proxy_pathlen(X509 *x);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
These functions retrieve information related to commonly used certificate extensions.
Packit c4476c
Packit c4476c
X509_get_pathlen() retrieves the path length extension from a certificate.
Packit c4476c
This extension is used to limit the length of a cert chain that may be
Packit c4476c
issued from that CA.
Packit c4476c
Packit c4476c
X509_get_extension_flags() retrieves general information about a certificate,
Packit c4476c
it will return one or more of the following flags ored together.
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item B<EXFLAG_V1>
Packit c4476c
Packit c4476c
The certificate is an obsolete version 1 certificate.
Packit c4476c
Packit c4476c
=item B<EXFLAG_BCONS>
Packit c4476c
Packit c4476c
The certificate contains a basic constraints extension.
Packit c4476c
Packit c4476c
=item B<EXFLAG_CA>
Packit c4476c
Packit c4476c
The certificate contains basic constraints and asserts the CA flag.
Packit c4476c
Packit c4476c
=item B<EXFLAG_PROXY>
Packit c4476c
Packit c4476c
The certificate is a valid proxy certificate.
Packit c4476c
Packit c4476c
=item B<EXFLAG_SI>
Packit c4476c
Packit c4476c
The certificate is self issued (that is subject and issuer names match).
Packit c4476c
Packit c4476c
=item B<EXFLAG_SS>
Packit c4476c
Packit c4476c
The subject and issuer names match and extension values imply it is self
Packit c4476c
signed.
Packit c4476c
Packit c4476c
=item B<EXFLAG_FRESHEST>
Packit c4476c
Packit c4476c
The freshest CRL extension is present in the certificate.
Packit c4476c
Packit c4476c
=item B<EXFLAG_CRITICAL>
Packit c4476c
Packit c4476c
The certificate contains an unhandled critical extension.
Packit c4476c
Packit c4476c
=item B<EXFLAG_INVALID>
Packit c4476c
Packit c4476c
Some certificate extension values are invalid or inconsistent. The
Packit c4476c
certificate should be rejected.
Packit c4476c
This bit may also be raised after an out-of-memory error while
Packit c4476c
processing the X509 object, so it may not be related to the processed
Packit c4476c
ASN1 object itself.
Packit c4476c
Packit c4476c
=item B<EXFLAG_INVALID_POLICY>
Packit c4476c
Packit c4476c
The NID_certificate_policies certificate extension is invalid or
Packit c4476c
inconsistent. The certificate should be rejected.
Packit c4476c
This bit may also be raised after an out-of-memory error while
Packit c4476c
processing the X509 object, so it may not be related to the processed
Packit c4476c
ASN1 object itself.
Packit c4476c
Packit c4476c
=item B<EXFLAG_KUSAGE>
Packit c4476c
Packit c4476c
The certificate contains a key usage extension. The value can be retrieved
Packit c4476c
using X509_get_key_usage().
Packit c4476c
Packit c4476c
=item B<EXFLAG_XKUSAGE>
Packit c4476c
Packit c4476c
The certificate contains an extended key usage extension. The value can be
Packit c4476c
retrieved using X509_get_extended_key_usage().
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
X509_get_key_usage() returns the value of the key usage extension.  If key
Packit c4476c
usage is present will return zero or more of the flags:
Packit c4476c
B<KU_DIGITAL_SIGNATURE>, B<KU_NON_REPUDIATION>, B<KU_KEY_ENCIPHERMENT>,
Packit c4476c
B<KU_DATA_ENCIPHERMENT>, B<KU_KEY_AGREEMENT>, B<KU_KEY_CERT_SIGN>,
Packit c4476c
B<KU_CRL_SIGN>, B<KU_ENCIPHER_ONLY> or B<KU_DECIPHER_ONLY> corresponding to
Packit c4476c
individual key usage bits. If key usage is absent then B<UINT32_MAX> is
Packit c4476c
returned.
Packit c4476c
Packit c4476c
X509_get_extended_key_usage() returns the value of the extended key usage
Packit c4476c
extension. If extended key usage is present it will return zero or more of the
Packit c4476c
flags: B<XKU_SSL_SERVER>, B<XKU_SSL_CLIENT>, B<XKU_SMIME>, B<XKU_CODE_SIGN>
Packit c4476c
B<XKU_OCSP_SIGN>, B<XKU_TIMESTAMP>, B<XKU_DVCS> or B<XKU_ANYEKU>. These
Packit c4476c
correspond to the OIDs B<id-kp-serverAuth>, B<id-kp-clientAuth>,
Packit c4476c
B<id-kp-emailProtection>, B<id-kp-codeSigning>, B<id-kp-OCSPSigning>,
Packit c4476c
B<id-kp-timeStamping>, B<id-kp-dvcs> and B<anyExtendedKeyUsage> respectively.
Packit c4476c
Additionally B<XKU_SGC> is set if either Netscape or Microsoft SGC OIDs are
Packit c4476c
present.
Packit c4476c
Packit c4476c
X509_get0_subject_key_id() returns an internal pointer to the subject key
Packit c4476c
identifier of B<x> as an B<ASN1_OCTET_STRING> or B<NULL> if the extension
Packit c4476c
is not present or cannot be parsed.
Packit c4476c
Packit c4476c
X509_get0_authority_key_id() returns an internal pointer to the authority key
Packit c4476c
identifier of B<x> as an B<ASN1_OCTET_STRING> or B<NULL> if the extension
Packit c4476c
is not present or cannot be parsed.
Packit c4476c
Packit c4476c
X509_get0_authority_issuer() returns an internal pointer to the authority
Packit c4476c
certificate issuer of B<x> as a stack of B<GENERAL_NAME> structures or
Packit c4476c
B<NULL> if the extension is not present or cannot be parsed.
Packit c4476c
Packit c4476c
X509_get0_authority_serial() returns an internal pointer to the authority
Packit c4476c
certificate serial number of B<x> as an B<ASN1_INTEGER> or B<NULL> if the
Packit c4476c
extension is not present or cannot be parsed.
Packit c4476c
Packit c4476c
X509_set_proxy_flag() marks the certificate with the B<EXFLAG_PROXY> flag.
Packit c4476c
This is for the users who need to mark non-RFC3820 proxy certificates as
Packit c4476c
such, as OpenSSL only detects RFC3820 compliant ones.
Packit c4476c
Packit c4476c
X509_set_proxy_pathlen() sets the proxy certificate path length for the given
Packit c4476c
certificate B<x>.  This is for the users who need to mark non-RFC3820 proxy
Packit c4476c
certificates as such, as OpenSSL only detects RFC3820 compliant ones.
Packit c4476c
Packit c4476c
X509_get_proxy_pathlen() returns the proxy certificate path length for the
Packit c4476c
given certificate B<x> if it is a proxy certificate.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
The value of the flags correspond to extension values which are cached
Packit c4476c
in the B<X509> structure. If the flags returned do not provide sufficient
Packit c4476c
information an application should examine extension values directly
Packit c4476c
for example using X509_get_ext_d2i().
Packit c4476c
Packit c4476c
If the key usage or extended key usage extension is absent then typically usage
Packit c4476c
is unrestricted. For this reason X509_get_key_usage() and
Packit c4476c
X509_get_extended_key_usage() return B<UINT32_MAX> when the corresponding
Packit c4476c
extension is absent. Applications can additionally check the return value of
Packit c4476c
X509_get_extension_flags() and take appropriate action is an extension is
Packit c4476c
absent.
Packit c4476c
Packit c4476c
If X509_get0_subject_key_id() returns B<NULL> then the extension may be
Packit c4476c
absent or malformed. Applications can determine the precise reason using
Packit c4476c
X509_get_ext_d2i().
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
X509_get_pathlen() returns the path length value, or -1 if the extension
Packit c4476c
is not present.
Packit c4476c
Packit c4476c
X509_get_extension_flags(), X509_get_key_usage() and
Packit c4476c
X509_get_extended_key_usage() return sets of flags corresponding to the
Packit c4476c
certificate extension values.
Packit c4476c
Packit c4476c
X509_get0_subject_key_id() returns the subject key identifier as a
Packit c4476c
pointer to an B<ASN1_OCTET_STRING> structure or B<NULL> if the extension
Packit c4476c
is absent or an error occurred during parsing.
Packit c4476c
Packit c4476c
X509_get_proxy_pathlen() returns the path length value if the given
Packit c4476c
certificate is a proxy one and has a path length set, and -1 otherwise.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<X509_check_purpose(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
X509_get_pathlen(), X509_set_proxy_flag(), X509_set_proxy_pathlen() and
Packit c4476c
X509_get_proxy_pathlen() were added in OpenSSL 1.1.0.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut