pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
tls_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2024 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef PCMK__CRM_COMMON_TLS_INTERNAL__H
11 #define PCMK__CRM_COMMON_TLS_INTERNAL__H
12 
13 #include <gnutls/gnutls.h> // gnutls_session_t, gnutls_dh_params_t, etc.
14 
15 #include <crm/common/ipc_internal.h> // pcmk__client_t
16 #include <crm/common/remote_internal.h> // pcmk__remote_t
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct {
23  bool server;
24  gnutls_dh_params_t dh_params;
25  gnutls_credentials_type_t cred_type;
26 
27  const char *ca_file;
28  const char *cert_file;
29  const char *crl_file;
30  const char *key_file;
31 
32  union {
33  gnutls_anon_server_credentials_t anon_s;
34  gnutls_anon_client_credentials_t anon_c;
35  gnutls_certificate_credentials_t cert;
36  gnutls_psk_server_credentials_t psk_s;
37  gnutls_psk_client_credentials_t psk_c;
38  } credentials;
39 } pcmk__tls_t;
40 
47 void pcmk__free_tls(pcmk__tls_t *tls);
48 
63 int pcmk__init_tls(pcmk__tls_t **tls, bool server,
64  gnutls_credentials_type_t cred_type);
65 
81 int pcmk__init_tls_dh(gnutls_dh_params_t *dh_params);
82 
92 gnutls_session_t pcmk__new_tls_session(pcmk__tls_t *tls, int csock);
93 
104 void pcmk__tls_add_psk_key(pcmk__tls_t *tls, gnutls_datum_t *key);
105 
117  gnutls_psk_server_credentials_function *cb);
118 
130 int pcmk__read_handshake_data(const pcmk__client_t *client);
131 
139 void pcmk__tls_check_cert_expiration(gnutls_session_t session);
140 
153 int pcmk__tls_client_handshake(pcmk__remote_t *remote, int timeout_sec,
154  int *gnutls_rc);
155 
167 int pcmk__tls_client_try_handshake(pcmk__remote_t *remote, int *gnutls_rc);
168 
176 bool pcmk__x509_enabled(void);
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 
182 #endif // PCMK__CRM_COMMON_TLS_INTERNAL__H
const char * key_file
Definition: tls_internal.h:30
gnutls_psk_client_credentials_t psk_c
Definition: tls_internal.h:37
int pcmk__tls_client_try_handshake(pcmk__remote_t *remote, int *gnutls_rc)
Definition: tls.c:480
int pcmk__init_tls(pcmk__tls_t **tls, bool server, gnutls_credentials_type_t cred_type)
Definition: tls.c:181
int pcmk__tls_client_handshake(pcmk__remote_t *remote, int timeout_sec, int *gnutls_rc)
Definition: tls.c:513
const char * cert_file
Definition: tls_internal.h:28
gnutls_anon_client_credentials_t anon_c
Definition: tls_internal.h:34
gnutls_credentials_type_t cred_type
Definition: tls_internal.h:25
void pcmk__tls_add_psk_callback(pcmk__tls_t *tls, gnutls_psk_server_credentials_function *cb)
Definition: tls.c:432
gnutls_session_t pcmk__new_tls_session(pcmk__tls_t *tls, int csock)
Definition: tls.c:315
gnutls_certificate_credentials_t cert
Definition: tls_internal.h:35
void pcmk__free_tls(pcmk__tls_t *tls)
Definition: tls.c:147
const char * ca_file
Definition: tls_internal.h:27
bool pcmk__x509_enabled(void)
Definition: tls.c:530
void pcmk__tls_add_psk_key(pcmk__tls_t *tls, gnutls_datum_t *key)
Definition: tls.c:424
gnutls_dh_params_t dh_params
Definition: tls_internal.h:24
const char * crl_file
Definition: tls_internal.h:29
gnutls_psk_server_credentials_t psk_s
Definition: tls_internal.h:36
gnutls_anon_server_credentials_t anon_s
Definition: tls_internal.h:33
int pcmk__read_handshake_data(const pcmk__client_t *client)
Definition: tls.c:399
int pcmk__init_tls_dh(gnutls_dh_params_t *dh_params)
Definition: tls.c:276
void pcmk__tls_check_cert_expiration(gnutls_session_t session)
Definition: tls.c:439