X509_STORE_CTX_new.pod 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. =pod
  2. =head1 NAME
  3. X509_STORE_CTX_new, X509_STORE_CTX_cleanup, X509_STORE_CTX_free, X509_STORE_CTX_init, X509_STORE_CTX_trusted_stack, X509_STORE_CTX_set_cert, X509_STORE_CTX_set_chain, X509_STORE_CTX_set0_crls, X509_STORE_CTX_get0_param, X509_STORE_CTX_set0_param, X509_STORE_CTX_set_default - X509_STORE_CTX initialisation
  4. =head1 SYNOPSIS
  5. #include <openssl/x509_vfy.h>
  6. X509_STORE_CTX *X509_STORE_CTX_new(void);
  7. void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);
  8. void X509_STORE_CTX_free(X509_STORE_CTX *ctx);
  9. int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,
  10. X509 *x509, STACK_OF(X509) *chain);
  11. void X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);
  12. void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx,X509 *x);
  13. void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx,STACK_OF(X509) *sk);
  14. void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk);
  15. X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);
  16. void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);
  17. int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);
  18. =head1 DESCRIPTION
  19. These functions initialise an B<X509_STORE_CTX> structure for subsequent use
  20. by X509_verify_cert().
  21. X509_STORE_CTX_new() returns a newly initialised B<X509_STORE_CTX> structure.
  22. X509_STORE_CTX_cleanup() internally cleans up an B<X509_STORE_CTX> structure.
  23. The context can then be reused with an new call to X509_STORE_CTX_init().
  24. X509_STORE_CTX_free() completely frees up B<ctx>. After this call B<ctx>
  25. is no longer valid.
  26. X509_STORE_CTX_init() sets up B<ctx> for a subsequent verification operation.
  27. The trusted certificate store is set to B<store>, the end entity certificate
  28. to be verified is set to B<x509> and a set of additional certificates (which
  29. will be untrusted but may be used to build the chain) in B<chain>. Any or
  30. all of the B<store>, B<x509> and B<chain> parameters can be B<NULL>.
  31. X509_STORE_CTX_trusted_stack() sets the set of trusted certificates of B<ctx>
  32. to B<sk>. This is an alternative way of specifying trusted certificates
  33. instead of using an B<X509_STORE>.
  34. X509_STORE_CTX_set_cert() sets the certificate to be vertified in B<ctx> to
  35. B<x>.
  36. X509_STORE_CTX_set_chain() sets the additional certificate chain used by B<ctx>
  37. to B<sk>.
  38. X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
  39. verification to B<sk>. These CRLs will only be used if CRL verification is
  40. enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
  41. used where additional "useful" CRLs are supplied as part of a protocol,
  42. for example in a PKCS#7 structure.
  43. X509_VERIFY_PARAM *X509_STORE_CTX_get0_param() retrieves an intenal pointer
  44. to the verification parameters associated with B<ctx>.
  45. X509_STORE_CTX_set0_param() sets the intenal verification parameter pointer
  46. to B<param>. After this call B<param> should not be used.
  47. X509_STORE_CTX_set_default() looks up and sets the default verification
  48. method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
  49. find an appropriate set of parameters from B<name>.
  50. =head1 NOTES
  51. The certificates and CRLs in a store are used internally and should B<not>
  52. be freed up until after the associated B<X509_STORE_CTX> is freed. Legacy
  53. applications might implicitly use an B<X509_STORE_CTX> like this:
  54. X509_STORE_CTX ctx;
  55. X509_STORE_CTX_init(&ctx, store, cert, chain);
  56. this is B<not> recommended in new applications they should instead do:
  57. X509_STORE_CTX *ctx;
  58. ctx = X509_STORE_CTX_new();
  59. if (ctx == NULL)
  60. /* Bad error */
  61. X509_STORE_CTX_init(ctx, store, cert, chain);
  62. =head1 BUGS
  63. The certificates and CRLs in a context are used internally and should B<not>
  64. be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
  65. should be made or reference counts increased instead.
  66. =head1 RETURN VALUES
  67. X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
  68. error occurred.
  69. X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
  70. X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
  71. structure or B<NULL> if an error occurred.
  72. X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(), X509_STORE_CTX_trusted_stack(),
  73. X509_STORE_CTX_set_cert(), X509_STORE_CTX_set_chain(),
  74. X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
  75. values.
  76. X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
  77. =head1 SEE ALSO
  78. L<X509_verify_cert(3)|X509_verify_cert(3)>
  79. L<X509_VERIFY_PARAM_set_flags(3)|X509_VERIFY_PARAM_set_flags(3)>
  80. =head1 HISTORY
  81. X509_STORE_CTX_set0_crls() was first added to OpenSSL 1.0.0
  82. =cut