SSL_CTX_set_cert_verify_callback.pod 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_cert_verify_callback - set peer certificate verification procedure
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *,void *), void *arg);
  7. =head1 DESCRIPTION
  8. SSL_CTX_set_cert_verify_callback() sets the verification callback function for
  9. I<ctx>. SSL objects that are created from I<ctx> inherit the setting valid at
  10. the time when L<SSL_new(3)|SSL_new(3)> is called.
  11. =head1 NOTES
  12. Whenever a certificate is verified during a SSL/TLS handshake, a verification
  13. function is called. If the application does not explicitly specify a
  14. verification callback function, the built-in verification function is used.
  15. If a verification callback I<callback> is specified via
  16. SSL_CTX_set_cert_verify_callback(), the supplied callback function is called
  17. instead. By setting I<callback> to NULL, the default behaviour is restored.
  18. When the verification must be performed, I<callback> will be called with
  19. the arguments callback(X509_STORE_CTX *x509_store_ctx, void *arg). The
  20. argument I<arg> is specified by the application when setting I<callback>.
  21. I<callback> should return 1 to indicate verification success and 0 to
  22. indicate verification failure. If SSL_VERIFY_PEER is set and I<callback>
  23. returns 0, the handshake will fail. As the verification procedure may
  24. allow to continue the connection in case of failure (by always returning 1)
  25. the verification result must be set in any case using the B<error>
  26. member of I<x509_store_ctx> so that the calling application will be informed
  27. about the detailed result of the verification procedure!
  28. Within I<x509_store_ctx>, I<callback> has access to the I<verify_callback>
  29. function set using L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>.
  30. =head1 WARNINGS
  31. Do not mix the verification callback described in this function with the
  32. B<verify_callback> function called during the verification process. The
  33. latter is set using the L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>
  34. family of functions.
  35. Providing a complete verification procedure including certificate purpose
  36. settings etc is a complex task. The built-in procedure is quite powerful
  37. and in most cases it should be sufficient to modify its behaviour using
  38. the B<verify_callback> function.
  39. =head1 BUGS
  40. =head1 RETURN VALUES
  41. SSL_CTX_set_cert_verify_callback() does not provide diagnostic information.
  42. =head1 SEE ALSO
  43. L<ssl(3)|ssl(3)>, L<SSL_CTX_set_verify(3)|SSL_CTX_set_verify(3)>,
  44. L<SSL_get_verify_result(3)|SSL_get_verify_result(3)>,
  45. L<SSL_CTX_load_verify_locations(3)|SSL_CTX_load_verify_locations(3)>
  46. =head1 HISTORY
  47. Previous to OpenSSL 0.9.7, the I<arg> argument to B<SSL_CTX_set_cert_verify_callback>
  48. was ignored, and I<callback> was called simply as
  49. int (*callback)(X509_STORE_CTX *)
  50. To compile software written for previous versions of OpenSSL, a dummy
  51. argument will have to be added to I<callback>.
  52. =cut