2
0

X509_STORE_CTX_new.pod 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. It must be called before each call to X509_verify_cert(), i.e. a B<ctx> is only
  28. good for one call to X509_verify_cert(); if you want to verify a second
  29. certificate with the same B<ctx> then you must call X509_STORE_CTX_cleanup()
  30. and then X509_STORE_CTX_init() again before the second call to
  31. X509_verify_cert(). The trusted certificate store is set to B<store>, the end
  32. entity certificate to be verified is set to B<x509> and a set of additional
  33. certificates (which will be untrusted but may be used to build the chain) in
  34. B<chain>. Any or all of the B<store>, B<x509> and B<chain> parameters can be
  35. B<NULL>.
  36. X509_STORE_CTX_trusted_stack() sets the set of trusted certificates of B<ctx>
  37. to B<sk>. This is an alternative way of specifying trusted certificates
  38. instead of using an B<X509_STORE>.
  39. X509_STORE_CTX_set_cert() sets the certificate to be vertified in B<ctx> to
  40. B<x>.
  41. X509_STORE_CTX_set_chain() sets the additional certificate chain used by B<ctx>
  42. to B<sk>.
  43. X509_STORE_CTX_set0_crls() sets a set of CRLs to use to aid certificate
  44. verification to B<sk>. These CRLs will only be used if CRL verification is
  45. enabled in the associated B<X509_VERIFY_PARAM> structure. This might be
  46. used where additional "useful" CRLs are supplied as part of a protocol,
  47. for example in a PKCS#7 structure.
  48. X509_VERIFY_PARAM *X509_STORE_CTX_get0_param() retrieves an intenal pointer
  49. to the verification parameters associated with B<ctx>.
  50. X509_STORE_CTX_set0_param() sets the intenal verification parameter pointer
  51. to B<param>. After this call B<param> should not be used.
  52. X509_STORE_CTX_set_default() looks up and sets the default verification
  53. method to B<name>. This uses the function X509_VERIFY_PARAM_lookup() to
  54. find an appropriate set of parameters from B<name>.
  55. =head1 NOTES
  56. The certificates and CRLs in a store are used internally and should B<not>
  57. be freed up until after the associated B<X509_STORE_CTX> is freed. Legacy
  58. applications might implicitly use an B<X509_STORE_CTX> like this:
  59. X509_STORE_CTX ctx;
  60. X509_STORE_CTX_init(&ctx, store, cert, chain);
  61. this is B<not> recommended in new applications they should instead do:
  62. X509_STORE_CTX *ctx;
  63. ctx = X509_STORE_CTX_new();
  64. if (ctx == NULL)
  65. /* Bad error */
  66. X509_STORE_CTX_init(ctx, store, cert, chain);
  67. =head1 BUGS
  68. The certificates and CRLs in a context are used internally and should B<not>
  69. be freed up until after the associated B<X509_STORE_CTX> is freed. Copies
  70. should be made or reference counts increased instead.
  71. =head1 RETURN VALUES
  72. X509_STORE_CTX_new() returns an newly allocates context or B<NULL> is an
  73. error occurred.
  74. X509_STORE_CTX_init() returns 1 for success or 0 if an error occurred.
  75. X509_STORE_CTX_get0_param() returns a pointer to an B<X509_VERIFY_PARAM>
  76. structure or B<NULL> if an error occurred.
  77. X509_STORE_CTX_cleanup(), X509_STORE_CTX_free(), X509_STORE_CTX_trusted_stack(),
  78. X509_STORE_CTX_set_cert(), X509_STORE_CTX_set_chain(),
  79. X509_STORE_CTX_set0_crls() and X509_STORE_CTX_set0_param() do not return
  80. values.
  81. X509_STORE_CTX_set_default() returns 1 for success or 0 if an error occurred.
  82. =head1 SEE ALSO
  83. L<X509_verify_cert(3)|X509_verify_cert(3)>
  84. L<X509_VERIFY_PARAM_set_flags(3)|X509_VERIFY_PARAM_set_flags(3)>
  85. =head1 HISTORY
  86. X509_STORE_CTX_set0_crls() was first added to OpenSSL 1.0.0
  87. =cut