X509_check_purpose.3ossl 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "X509_CHECK_PURPOSE 3ossl"
  58. .TH X509_CHECK_PURPOSE 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. X509_check_purpose \- Check the purpose of a certificate
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. .Vb 1
  68. \& #include <openssl/x509v3.h>
  69. \&
  70. \& int X509_check_purpose(X509 *x, int id, int ca);
  71. .Ve
  72. .SH DESCRIPTION
  73. .IX Header "DESCRIPTION"
  74. This function checks if certificate \fIx\fR was created with the purpose
  75. represented by \fIid\fR. If \fIca\fR is nonzero, then certificate \fIx\fR is
  76. checked to determine if it's a possible CA with various levels of certainty
  77. possibly returned. The certificate \fIx\fR must be a complete certificate
  78. otherwise the function returns an error.
  79. .PP
  80. Below are the potential ID's that can be checked:
  81. .PP
  82. .Vb 10
  83. \& # define X509_PURPOSE_SSL_CLIENT 1
  84. \& # define X509_PURPOSE_SSL_SERVER 2
  85. \& # define X509_PURPOSE_NS_SSL_SERVER 3
  86. \& # define X509_PURPOSE_SMIME_SIGN 4
  87. \& # define X509_PURPOSE_SMIME_ENCRYPT 5
  88. \& # define X509_PURPOSE_CRL_SIGN 6
  89. \& # define X509_PURPOSE_ANY 7
  90. \& # define X509_PURPOSE_OCSP_HELPER 8
  91. \& # define X509_PURPOSE_TIMESTAMP_SIGN 9
  92. \& # define X509_PURPOSE_CODE_SIGN 10
  93. .Ve
  94. .PP
  95. The checks performed take into account the X.509 extensions
  96. keyUsage, extendedKeyUsage, and basicConstraints.
  97. .SH "RETURN VALUES"
  98. .IX Header "RETURN VALUES"
  99. For non-CA checks
  100. .IP "\-1 an error condition has occurred" 4
  101. .IX Item "-1 an error condition has occurred"
  102. .PD 0
  103. .IP " 1 if the certificate was created to perform the purpose represented by \fIid\fR" 4
  104. .IX Item " 1 if the certificate was created to perform the purpose represented by id"
  105. .IP " 0 if the certificate was not created to perform the purpose represented by \fIid\fR" 4
  106. .IX Item " 0 if the certificate was not created to perform the purpose represented by id"
  107. .PD
  108. .PP
  109. For CA checks the below integers could be returned with the following meanings:
  110. .IP "\-1 an error condition has occurred" 4
  111. .IX Item "-1 an error condition has occurred"
  112. .PD 0
  113. .IP " 0 not a CA or does not have the purpose represented by \fIid\fR" 4
  114. .IX Item " 0 not a CA or does not have the purpose represented by id"
  115. .IP " 1 is a CA." 4
  116. .IX Item " 1 is a CA."
  117. .IP " 2 Only possible in old versions of openSSL when basicConstraints are absent. New versions will not return this value. May be a CA" 4
  118. .IX Item " 2 Only possible in old versions of openSSL when basicConstraints are absent. New versions will not return this value. May be a CA"
  119. .IP " 3 basicConstraints absent but self signed V1." 4
  120. .IX Item " 3 basicConstraints absent but self signed V1."
  121. .IP " 4 basicConstraints absent but keyUsage present and keyCertSign asserted." 4
  122. .IX Item " 4 basicConstraints absent but keyUsage present and keyCertSign asserted."
  123. .IP " 5 legacy Netscape specific CA Flags present" 4
  124. .IX Item " 5 legacy Netscape specific CA Flags present"
  125. .PD
  126. .SH COPYRIGHT
  127. .IX Header "COPYRIGHT"
  128. Copyright 2019\-2021 The OpenSSL Project Authors. All Rights Reserved.
  129. Licensed under the Apache License 2.0 (the "License"). You may not use this
  130. file except in compliance with the License. You can obtain a copy in the file
  131. LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.