openssl.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*-------------------------------------------------------------------------
  2. *
  3. * openssl.h
  4. * OpenSSL supporting functionality shared between frontend and backend
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * IDENTIFICATION
  10. * src/include/common/openssl.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef COMMON_OPENSSL_H
  15. #define COMMON_OPENSSL_H
  16. #ifdef USE_OPENSSL
  17. #include <openssl/ssl.h>
  18. /*
  19. * OpenSSL doesn't provide any very nice way to identify the min/max
  20. * protocol versions the library supports, so we fake it as best we can.
  21. * Note in particular that this doesn't account for restrictions that
  22. * might be specified in the installation's openssl.cnf.
  23. *
  24. * We disable SSLv3 and older in library setup, so TLSv1 is the oldest
  25. * protocol version of interest.
  26. */
  27. #define MIN_OPENSSL_TLS_VERSION "TLSv1"
  28. #if defined(TLS1_3_VERSION)
  29. #define MAX_OPENSSL_TLS_VERSION "TLSv1.3"
  30. #elif defined(TLS1_2_VERSION)
  31. #define MAX_OPENSSL_TLS_VERSION "TLSv1.2"
  32. #elif defined(TLS1_1_VERSION)
  33. #define MAX_OPENSSL_TLS_VERSION "TLSv1.1"
  34. #else
  35. #define MAX_OPENSSL_TLS_VERSION "TLSv1"
  36. #endif
  37. /* src/common/protocol_openssl.c */
  38. #ifndef SSL_CTX_set_min_proto_version
  39. extern int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version);
  40. extern int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version);
  41. #endif
  42. #endif /* USE_OPENSSL */
  43. #endif /* COMMON_OPENSSL_H */