X509_STORE_CTX_new.pod 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. =pod
  2. =head1 NAME
  3. X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free,
  4. X509_STORE_CTX_init, X509_STORE_CTX_set0_trusted_stack, X509_STORE_CTX_set_cert,
  5. X509_STORE_CTX_set0_crls,
  6. X509_STORE_CTX_get0_chain, X509_STORE_CTX_set0_verified_chain,
  7. X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param,
  8. X509_STORE_CTX_get0_untrusted, X509_STORE_CTX_set0_untrusted,
  9. X509_STORE_CTX_get_num_untrusted,
  10. X509_STORE_CTX_set_default,
  11. X509_STORE_CTX_set_verify,
  12. X509_STORE_CTX_verify_fn
  13. - X509_STORE_CTX initialisation
  14. =head1 SYNOPSIS
  15. #include <openssl/x509_vfy.h>
  16. X509_STORE_CTX *X509_STORE_CTX_new(void);
  17. void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
  18. void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
  19. int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
  20. X509 *x509, STACK_OF(X509) *chain);
  21. void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
  22. void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x);
  23. STACK_OF(X509) *X509_STORE_CTX_get0_chain(X609_STORE_CTX *ctx);
  24. void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *chain);
  25. void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
  26. X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
  27. void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
  28. int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
  29. STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);
  30. void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
  31. int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);
  32. typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);
  33. void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify);
  34. =head1 DESCRIPTION
  35. These functions initialise an B<X509_STORE_CTX> structure for subsequent use
  36. by X509_verify_cert().
  37. X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
  38. X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
  39. The context can then be reused with an new call to X509_STORE_CTX_init().
  40. X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
  41. is no longer valid.
  42. If B<ctx> is NULL nothing is done.
  43. X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
  44. It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
  45. good for one call to X509_verify_cert(); if you want to verify a second
  46. certificate with the same B<ctx> then you must call X509_STORE_CTX_cleanup()
  47. and then X509_STORE_CTX_init() again before the second call to
  48. X509_verify_cert(). The trusted certificate store is set to B<store>, the end
  49. entity certificate to be verified is set to B<x509> and a set of additional
  50. certificates (which will be untrusted but may be used to build the chain) in
  51. B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
  52. B<NULL>.
  53. X509_STORE_CTX_set0_trusted_stack() sets the set of trusted certificates of
  54. B<ctx> to B<sk>. This is an alternative way of specifying trusted certificates
  55. instead of using an B<X509_STORE>.
  56. X509_STORE_CTX_set_cert() sets the certificate to be verified in B<ctx> to
  57. B<x>.
  58. X509_STORE_CTX_set0_verified_chain() sets the validated chain used
  59. by B<ctx> to be B<chain>.
  60. Ownership of the chain is transferred to B<ctx> and should not be
  61. free'd by the caller.
  62. X509_STORE_CTX_get0_chain() returns a the internal pointer used by the
  63. B<ctx> that contains the validated chain.
  64. X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
  65. verification to B<sk>. These CRLs will only be used if CRL verification is
  66. enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
  67. used where additional "useful" CRLs are supplied as part of a protocol,
  68. for example in a PKCS#7 structure.
  69. X509_STORE_CTX_get0_param() retrieves an internal pointer
  70. to the verification parameters associated with B<ctx>.
  71. X509_STORE_CTX_get0_untrusted() retrieves an internal pointer to the
  72. stack of untrusted certificates associated with B<ctx>.
  73. X509_STORE_CTX_set0_untrusted() sets the internal point to the stack
  74. of untrusted certificates associated with B<ctx> to B<sk>.
  75. X509_STORE_CTX_set0_param() sets the internal verification parameter pointer
  76. to B<param>. After this call B<param> should not be used.
  77. X509_STORE_CTX_set_default() looks up and sets the default verification
  78. method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
  79. find an appropriate set of parameters from B<name>.
  80. X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
  81. that were used in building the chain following a call to X509_verify_cert().
  82. X509_STORE_CTX_set_verify() provides the capability for overriding the default
  83. verify function. This function is responsible for verifying chain signatures and
  84. expiration times.
  85. A verify function is defined as an X509_STORE_CTX_verify type which has the
  86. following signature:
  87. int (*verify)(X509_STORE_CTX *);
  88. This function should receive the current X509_STORE_CTX as a parameter and
  89. return 1 on success or 0 on failure.
  90. =head1 NOTES
  91. The certificates and CRLs in a store are used internally and should B<not>
  92. be freed up until after the associated B<X509_STORE_CTX> is freed.
  93. =head1 BUGS
  94. The certificates and CRLs in a context are used internally and should B<not>
  95. be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
  96. should be made or reference counts increased instead.
  97. =head1 RETURN VALUES
  98. X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
  99. error occurred.
  100. X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
  101. X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
  102. structure or B<NULL> if an error occurred.
  103. X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(),
  104. X509_STORE_CTX_set0_trusted_stack(),
  105. X509_STORE_CTX_set_cert(),
  106. X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
  107. values.
  108. X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
  109. X509_STORE_CTX_get_num_untrusted() returns the number of untrusted certificates
  110. used.
  111. =head1 SEE ALSO
  112. L<X509_verify_cert(3)>
  113. L<X509_VERIFY_PARAM_set_flags(3)>
  114. =head1 HISTORY
  115. X509_STORE_CTX_set0_crls() was first added to OpenSSL 1.0.0
  116. X509_STORE_CTX_get_num_untrusted() was first added to OpenSSL 1.1.0
  117. =head1 COPYRIGHT
  118. Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
  119. Licensed under the OpenSSL license (the "License"). You may not use
  120. this file except in compliance with the License. You can obtain a copy
  121. in the file LICENSE in the source distribution or at
  122. L<https://www.openssl.org/source/license.html>.
  123. =cut