1 /*
2   Copyright 2021 Northern.tech AS
3 
4   This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of the GNU General Public License as published by the
8   Free Software Foundation; version 3.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
18 
19   To the extent this program is licensed as part of the Enterprise
20   versions of CFEngine, the applicable Commercial Open Source License
21   (COSL) may apply to this file if you as a licensee so wish it. See
22   included file COSL.txt.
23 */
24 
25 
26 #ifndef CFENGINE_TLS_GENERIC_H
27 #define CFENGINE_TLS_GENERIC_H
28 
29 
30 #include <cfnet.h>
31 
32 #include <openssl/ssl.h>
33 
34 #include <logging.h>                                            /* LogLevel */
35 
36 
37 extern int CONNECTIONINFO_SSL_IDX;
38 
39 
40 bool TLSGenericInitialize(void);
41 int TLSVerifyCallback(X509_STORE_CTX *ctx, void *arg);
42 int TLSVerifyPeer(ConnectionInfo *conn_info, const char *remoteip, const char *username);
43 X509 *TLSGenerateCertFromPrivKey(RSA *privkey);
44 int TLSLogError(SSL *ssl, LogLevel level, const char *prepend, int code);
45 int TLSSend(SSL *ssl, const char *buffer, int length);
46 int TLSRecv(SSL *ssl, char *buffer, int toget);
47 int TLSRecvLines(SSL *ssl, char *buf, size_t buf_size);
48 void TLSSetDefaultOptions(SSL_CTX *ssl_ctx, const char *min_version);
49 const char *TLSErrorString(intmax_t errcode);
50 bool TLSSetCipherList(SSL_CTX *ssl_ctx, const char *cipher_list);
51 
52 #endif
53