1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos X509_check_purpose - Check the purpose of a certificate 6 1.1 christos 7 1.1 christos =head1 SYNOPSIS 8 1.1 christos 9 1.1 christos #include <openssl/x509v3.h> 10 1.1 christos 11 1.1.1.3 christos int X509_check_purpose(X509 *x, int id, int ca); 12 1.1 christos 13 1.1 christos =head1 DESCRIPTION 14 1.1 christos 15 1.1 christos This function checks if certificate I<x> was created with the purpose 16 1.1 christos represented by I<id>. If I<ca> is nonzero, then certificate I<x> is 17 1.1 christos checked to determine if it's a possible CA with various levels of certainty 18 1.1.1.3 christos possibly returned. The certificate I<x> must be a complete certificate 19 1.1.1.3 christos otherwise the function returns an error. 20 1.1 christos 21 1.1 christos Below are the potential ID's that can be checked: 22 1.1 christos 23 1.1 christos # define X509_PURPOSE_SSL_CLIENT 1 24 1.1 christos # define X509_PURPOSE_SSL_SERVER 2 25 1.1 christos # define X509_PURPOSE_NS_SSL_SERVER 3 26 1.1 christos # define X509_PURPOSE_SMIME_SIGN 4 27 1.1 christos # define X509_PURPOSE_SMIME_ENCRYPT 5 28 1.1 christos # define X509_PURPOSE_CRL_SIGN 6 29 1.1 christos # define X509_PURPOSE_ANY 7 30 1.1 christos # define X509_PURPOSE_OCSP_HELPER 8 31 1.1 christos # define X509_PURPOSE_TIMESTAMP_SIGN 9 32 1.1 christos 33 1.1.1.3 christos The checks performed take into account the X.509 extensions 34 1.1.1.3 christos keyUsage, extendedKeyUsage, and basicConstraints. 35 1.1.1.3 christos 36 1.1 christos =head1 RETURN VALUES 37 1.1 christos 38 1.1 christos For non-CA checks 39 1.1 christos 40 1.1 christos =over 4 41 1.1 christos 42 1.1.1.2 christos =item -1 an error condition has occurred 43 1.1 christos 44 1.1 christos =item E<32>1 if the certificate was created to perform the purpose represented by I<id> 45 1.1 christos 46 1.1 christos =item E<32>0 if the certificate was not created to perform the purpose represented by I<id> 47 1.1 christos 48 1.1 christos =back 49 1.1 christos 50 1.1 christos For CA checks the below integers could be returned with the following meanings: 51 1.1 christos 52 1.1 christos =over 4 53 1.1 christos 54 1.1.1.2 christos =item -1 an error condition has occurred 55 1.1 christos 56 1.1 christos =item E<32>0 not a CA or does not have the purpose represented by I<id> 57 1.1 christos 58 1.1 christos =item E<32>1 is a CA. 59 1.1 christos 60 1.1 christos =item E<32>2 Only possible in old versions of openSSL when basicConstraints are absent. 61 1.1 christos New versions will not return this value. May be a CA 62 1.1 christos 63 1.1 christos =item E<32>3 basicConstraints absent but self signed V1. 64 1.1 christos 65 1.1 christos =item E<32>4 basicConstraints absent but keyUsage present and keyCertSign asserted. 66 1.1 christos 67 1.1 christos =item E<32>5 legacy Netscape specific CA Flags present 68 1.1 christos 69 1.1 christos =back 70 1.1 christos 71 1.1 christos =head1 COPYRIGHT 72 1.1 christos 73 1.1.1.3 christos Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 74 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use this 75 1.1 christos file except in compliance with the License. You can obtain a copy in the file 76 1.1 christos LICENSE in the source distribution or at L<https://www.openssl.org/source/license.html>. 77 1.1 christos 78 1.1 christos =cut 79