X509_check_purpose.pod 2.3 KB

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