security.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef NETDATA_SECURITY_H
  2. # define NETDATA_SECURITY_H
  3. # define NETDATA_SSL_HANDSHAKE_COMPLETE 0 //All the steps were successful
  4. # define NETDATA_SSL_START 1 //Starting handshake, conn variable is NULL
  5. # define NETDATA_SSL_WANT_READ 2 //The connection wanna read from socket
  6. # define NETDATA_SSL_WANT_WRITE 4 //The connection wanna write on socket
  7. # define NETDATA_SSL_NO_HANDSHAKE 8 //Continue without encrypt connection.
  8. # define NETDATA_SSL_OPTIONAL 16 //Flag to define the HTTP request
  9. # define NETDATA_SSL_FORCE 32 //We only accepts HTTPS request
  10. # define NETDATA_SSL_INVALID_CERTIFICATE 64 //Accepts invalid certificate
  11. # define NETDATA_SSL_VALID_CERTIFICATE 128 //Accepts invalid certificate
  12. # define NETDATA_SSL_PROXY_HTTPS 256 //Proxy is using HTTPS
  13. #define NETDATA_SSL_CONTEXT_SERVER 0
  14. #define NETDATA_SSL_CONTEXT_STREAMING 1
  15. #define NETDATA_SSL_CONTEXT_EXPORTING 2
  16. # ifdef ENABLE_HTTPS
  17. #define OPENSSL_VERSION_095 0x00905100L
  18. #define OPENSSL_VERSION_097 0x0907000L
  19. #define OPENSSL_VERSION_110 0x10100000L
  20. #define OPENSSL_VERSION_111 0x10101000L
  21. # include <openssl/ssl.h>
  22. # include <openssl/err.h>
  23. # if (SSLEAY_VERSION_NUMBER >= OPENSSL_VERSION_097) && (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_110)
  24. # include <openssl/conf.h>
  25. # endif
  26. struct netdata_ssl{
  27. SSL *conn; //SSL connection
  28. uint32_t flags; //The flags for SSL connection
  29. };
  30. extern SSL_CTX *netdata_exporting_ctx;
  31. extern SSL_CTX *netdata_client_ctx;
  32. extern SSL_CTX *netdata_srv_ctx;
  33. extern const char *security_key;
  34. extern const char *security_cert;
  35. extern const char *tls_version;
  36. extern const char *tls_ciphers;
  37. extern int netdata_validate_server;
  38. extern int security_location_for_context(SSL_CTX *ctx,char *file,char *path);
  39. void security_openssl_library();
  40. void security_clean_openssl();
  41. void security_start_ssl(int selector);
  42. int security_process_accept(SSL *ssl,int msg);
  43. int security_test_certificate(SSL *ssl);
  44. SSL_CTX * security_initialize_openssl_client();
  45. # endif //ENABLE_HTTPS
  46. #endif //NETDATA_SECURITY_H