0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-07 02:30:12 +00:00
netdata_netdata/libnetdata/socket/security.h
thiagoftsm 551617bd32 Add configurable default locations for trusted CA certificates ()
* sslcertificate: Trust certificate

The netdata could not allow invalid certificate or certificate with invalid chain
this commit fixes this!

* sslcertificate: Changing name

We are binging the same names used by the OpenSSL library to simplify the understand of the parameters

* sslcertificate: Name changes and explicity directory

This commit fix the problem with Streams and rename correctly the files in the option, it also uses stat to define the existence of a file

* sslcertificate: Documentation

Fix grammar for the newest section in the documentation

* sslcertificate: Rename variables

The old variables did not represent well what they are doing, so it was renamed
2019-07-29 15:27:32 +03:00

46 lines
1.7 KiB
C

#ifndef NETDATA_SECURITY_H
# define NETDATA_SECURITY_H
# define NETDATA_SSL_HANDSHAKE_COMPLETE 0 //All the steps were successful
# define NETDATA_SSL_START 1 //Starting handshake, conn variable is NULL
# define NETDATA_SSL_WANT_READ 2 //The connection wanna read from socket
# define NETDATA_SSL_WANT_WRITE 4 //The connection wanna write on socket
# define NETDATA_SSL_NO_HANDSHAKE 8 //Continue without encrypt connection.
# define NETDATA_SSL_OPTIONAL 16 //Flag to define the HTTP request
# define NETDATA_SSL_FORCE 32 //We only accepts HTTPS request
# define NETDATA_SSL_INVALID_CERTIFICATE 64 //Accepts invalid certificate
# define NETDATA_SSL_VALID_CERTIFICATE 128 //Accepts invalid certificate
#define NETDATA_SSL_CONTEXT_SERVER 0
#define NETDATA_SSL_CONTEXT_STREAMING 1
#define NETDATA_SSL_CONTEXT_OPENTSDB 2
# ifdef ENABLE_HTTPS
# include <openssl/ssl.h>
# include <openssl/err.h>
# if (SSLEAY_VERSION_NUMBER >= 0x0907000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
# include <openssl/conf.h>
# endif
struct netdata_ssl{
SSL *conn; //SSL connection
int flags; //The flags for SSL connection
};
extern SSL_CTX *netdata_opentsdb_ctx;
extern SSL_CTX *netdata_client_ctx;
extern SSL_CTX *netdata_srv_ctx;
extern const char *security_key;
extern const char *security_cert;
extern int netdata_validate_server;
extern int security_location_for_context(SSL_CTX *ctx,char *file,char *path);
void security_openssl_library();
void security_clean_openssl();
void security_start_ssl(int selector);
int security_process_accept(SSL *ssl,int msg);
int security_test_certificate(SSL *ssl);
# endif //ENABLE_HTTPS
#endif //NETDATA_SECURITY_H