security.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_CONTEXT_SERVER 0
  13. #define NETDATA_SSL_CONTEXT_STREAMING 1
  14. #define NETDATA_SSL_CONTEXT_OPENTSDB 2
  15. # ifdef ENABLE_HTTPS
  16. # include <openssl/ssl.h>
  17. # include <openssl/err.h>
  18. # if (SSLEAY_VERSION_NUMBER >= 0x0907000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
  19. # include <openssl/conf.h>
  20. # endif
  21. struct netdata_ssl{
  22. SSL *conn; //SSL connection
  23. int flags;
  24. };
  25. extern SSL_CTX *netdata_opentsdb_ctx;
  26. extern SSL_CTX *netdata_client_ctx;
  27. extern SSL_CTX *netdata_srv_ctx;
  28. extern const char *security_key;
  29. extern const char *security_cert;
  30. extern int netdata_use_ssl_on_stream;
  31. extern int netdata_use_ssl_on_http;
  32. extern int netdata_validate_server;
  33. void security_openssl_library();
  34. void security_clean_openssl();
  35. void security_start_ssl(int selector);
  36. int security_process_accept(SSL *ssl,int msg);
  37. int security_test_certificate(SSL *ssl);
  38. # endif //ENABLE_HTTPS
  39. #endif //NETDATA_SECURITY_H