Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 2 | * @file session_client_ch.h |
| 3 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * @brief libnetconf2 Call Home session client manipulation |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 5 | * |
Michal Vasko | 95ea9ff | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 6 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_SESSION_CLIENT_CH_H_ |
| 17 | #define NC_SESSION_CLIENT_CH_H_ |
| 18 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 23 | #include <libyang/libyang.h> |
| 24 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 25 | #ifdef NC_ENABLED_SSH |
| 26 | # include <libssh/libssh.h> |
| 27 | #endif |
| 28 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 29 | #include "messages_client.h" |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 30 | #include "netconf.h" |
| 31 | #include "session.h" |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 32 | |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 33 | #if defined (NC_ENABLED_SSH) || defined (NC_ENABLED_TLS) |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 34 | |
| 35 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 36 | * @defgroup client_ch Client-side Call Home |
| 37 | * @ingroup client |
| 38 | * |
| 39 | * @brief Call Home functionality for client-side applications. |
| 40 | * @{ |
| 41 | */ |
| 42 | |
| 43 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 44 | * @brief Accept a Call Home connection on any of the listening binds. |
| 45 | * |
| 46 | * @param[in] timeout Timeout for receiving a new connection in milliseconds, 0 for |
| 47 | * non-blocking call, -1 for infinite waiting. |
| 48 | * @param[in] ctx Session context to use. Can be NULL. |
| 49 | * @param[out] session New session. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 50 | * @return 1 on success, 0 on timeout, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 51 | */ |
| 52 | int nc_accept_callhome(int timeout, struct ly_ctx *ctx, struct nc_session **session); |
| 53 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 54 | /** @} Client-side Call Home */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 55 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 56 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 57 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 58 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 59 | |
| 60 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 61 | * @defgroup client_ch_ssh Client-side Call Home on SSH |
| 62 | * @ingroup client_ch |
| 63 | * |
| 64 | * @brief SSH settings for the Call Home functionality |
| 65 | * @{ |
| 66 | */ |
| 67 | |
| 68 | /** |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 69 | * @brief Set SSH Call Home authentication hostkey check (knownhosts) callback. |
| 70 | * |
| 71 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 72 | * freeing the private data when necessary (the private data can be obtained by |
| 73 | * nc_client_ssh_ch_get_auth_hostkey_check_clb()). |
Michal Vasko | ef112d7 | 2016-02-18 13:28:25 +0100 | [diff] [blame] | 74 | * |
| 75 | * @param[in] auth_hostkey_check Function to call, returns 0 on success, non-zero in error. |
| 76 | * If NULL, the default callback is set. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 77 | * @param[in] priv Optional private data to be passed to the callback function. |
Michal Vasko | ef112d7 | 2016-02-18 13:28:25 +0100 | [diff] [blame] | 78 | */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 79 | void nc_client_ssh_ch_set_auth_hostkey_check_clb(int (*auth_hostkey_check)(const char *hostname, ssh_session session, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 80 | void *priv); |
Michal Vasko | ef112d7 | 2016-02-18 13:28:25 +0100 | [diff] [blame] | 81 | |
| 82 | /** |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 83 | * @brief Get currently set SSH Call Home authentication hostkey check (knownhosts) callback and its private data |
| 84 | * previously set by nc_client_ssh_ch_set_auth_hostkey_check_clb(). |
| 85 | * |
| 86 | * @param[out] auth_hostkey_check Currently set callback, NULL in case of the default callback. |
| 87 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 88 | */ |
| 89 | void nc_client_ssh_ch_get_auth_hostkey_check_clb(int (**auth_hostkey_check)(const char *hostname, ssh_session session, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 90 | void **priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 91 | /** |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 92 | * @brief Set SSH Call Home password authentication callback. |
| 93 | * |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 94 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 95 | * freeing the private data when necessary (the private data can be obtained by |
| 96 | * nc_client_ssh_ch_get_auth_password_clb()). |
| 97 | * |
Michal Vasko | fdfd9dd | 2016-02-29 10:18:46 +0100 | [diff] [blame] | 98 | * @param[in] auth_password Function to call, returns the password for username\@hostname. |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 99 | * If NULL, the default callback is set. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 100 | * @param[in] priv Optional private data to be passed to the callback function. |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 101 | */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 102 | void nc_client_ssh_ch_set_auth_password_clb(char *(*auth_password)(const char *username, const char *hostname, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 103 | void *priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * @brief Get currently set SSH Call Home password authentication callback and its private data |
| 107 | * previously set by nc_client_ssh_ch_set_auth_password_clb(). |
| 108 | * |
| 109 | * @param[out] auth_password Currently set callback, NULL in case of the default callback. |
| 110 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 111 | */ |
| 112 | void nc_client_ssh_ch_get_auth_password_clb(char *(**auth_password)(const char *username, const char *hostname, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 113 | void **priv); |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * @brief Set SSH Call Home interactive authentication callback. |
| 117 | * |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 118 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 119 | * freeing the private data when necessary (the private data can be obtained by |
| 120 | * nc_client_ssh_ch_get_auth_interactive_clb()). |
| 121 | * |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 122 | * @param[in] auth_interactive Function to call for every question, returns the answer for |
| 123 | * authentication name with instruction and echoing prompt. |
| 124 | * If NULL, the default callback is set. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 125 | * @param[in] priv Optional private data to be passed to the callback function. |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 126 | */ |
| 127 | void nc_client_ssh_ch_set_auth_interactive_clb(char *(*auth_interactive)(const char *auth_name, const char *instruction, |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 128 | const char *prompt, int echo, void *priv), |
| 129 | void *priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * @brief Get currently set SSH Call Home interactive authentication callback and its private data |
| 133 | * previously set by nc_client_ssh_ch_set_auth_interactive_clb(). |
| 134 | * |
| 135 | * @param[out] auth_interactive Currently set callback, NULL in case of the default callback. |
| 136 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 137 | */ |
| 138 | void nc_client_ssh_ch_get_auth_interactive_clb(char *(**auth_interactive)(const char *auth_name, const char *instruction, |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 139 | const char *prompt, int echo, void *priv), |
| 140 | void **priv); |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * @brief Set SSH Call Home publickey authentication encrypted private key passphrase callback. |
| 144 | * |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 145 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 146 | * freeing the private data when necessary (the private data can be obtained by |
| 147 | * nc_client_ssh_ch_get_auth_privkey_passphrase_clb()). |
| 148 | * |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 149 | * @param[in] auth_privkey_passphrase Function to call for every question, returns |
| 150 | * the passphrase for the specific private key. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 151 | * @param[in] priv Optional private data to be passed to the callback function. |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 152 | */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 153 | void nc_client_ssh_ch_set_auth_privkey_passphrase_clb(char *(*auth_privkey_passphrase)(const char *privkey_path, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 154 | void *priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 155 | |
| 156 | /** |
| 157 | * @brief Get currently set SSH Call Home publickey authentication encrypted private key passphrase callback and its |
| 158 | * private data previously set by nc_client_ssh_ch_set_auth_privkey_passphrase_clb(). |
| 159 | * |
| 160 | * @param[out] auth_privkey_passphrase Currently set callback, NULL in case of the default callback. |
| 161 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 162 | */ |
| 163 | void nc_client_ssh_ch_get_auth_privkey_passphrase_clb(char *(**auth_privkey_passphrase)(const char *privkey_path, void *priv), |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 164 | void **priv); |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 165 | |
| 166 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 167 | * @brief Add a new client bind and start listening on it for SSH Call Home connections. |
| 168 | * |
| 169 | * @param[in] address IP address to bind to. |
| 170 | * @param[in] port Port to bind to. |
| 171 | * @return 0 on success, -1 on error. |
| 172 | */ |
| 173 | int nc_client_ssh_ch_add_bind_listen(const char *address, uint16_t port); |
| 174 | |
| 175 | /** |
| 176 | * @brief Remove an SSH listening client bind. |
| 177 | * |
| 178 | * @param[in] address IP address the socket was bound to. NULL matches all. |
| 179 | * @param[in] port Port the socket was bound to. 0 matches all. |
| 180 | * @return 0 on success, -1 on not found. |
| 181 | */ |
| 182 | int nc_client_ssh_ch_del_bind(const char *address, uint16_t port); |
| 183 | |
| 184 | /** |
| 185 | * @brief Add an SSH public and private key pair to be used for Call Home client authentication. |
| 186 | * |
| 187 | * Private key can be encrypted, the passphrase will be asked for before using it. |
| 188 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 189 | * @param[in] pub_key Path to the public key. |
| 190 | * @param[in] priv_key Path to the private key. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 191 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 192 | */ |
| 193 | int nc_client_ssh_ch_add_keypair(const char *pub_key, const char *priv_key); |
| 194 | |
| 195 | /** |
| 196 | * @brief Remove an SSH public and private key pair that was used for Call Home client authentication. |
| 197 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 198 | * @param[in] idx Index of the keypair starting with 0. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 199 | * @return 0 on success, -1 on error. |
| 200 | */ |
| 201 | int nc_client_ssh_ch_del_keypair(int idx); |
| 202 | |
| 203 | /** |
| 204 | * @brief Get the number of public an private key pairs set to be used for Call Home client authentication. |
| 205 | * |
| 206 | * @return Keypair count. |
| 207 | */ |
| 208 | int nc_client_ssh_ch_get_keypair_count(void); |
| 209 | |
| 210 | /** |
| 211 | * @brief Get a specific keypair set to be used for Call Home client authentication. |
| 212 | * |
| 213 | * @param[in] idx Index of the specific keypair. |
| 214 | * @param[out] pub_key Path to the public key. |
| 215 | * @param[out] priv_key Path to the private key. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 216 | * @return 0 on success, -1 on error. |
| 217 | */ |
| 218 | int nc_client_ssh_ch_get_keypair(int idx, const char **pub_key, const char **priv_key); |
| 219 | |
| 220 | /** |
| 221 | * @brief Set SSH Call Home authentication method preference. |
| 222 | * |
Radek Krejci | 62aa064 | 2017-05-25 16:33:49 +0200 | [diff] [blame] | 223 | * The default preference is as follows: |
| 224 | * - public key authentication (3) |
| 225 | * - password authentication (2) |
| 226 | * - interactive authentication (1) |
| 227 | * |
| 228 | * @param[in] auth_type Authentication method to modify the preference of. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 229 | * @param[in] pref Preference of @p auth_type. Higher number increases priority, negative values disable the method. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 230 | */ |
| 231 | void nc_client_ssh_ch_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref); |
| 232 | |
| 233 | /** |
| 234 | * @brief Get SSH Call Home authentication method preference. |
| 235 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 236 | * @param[in] auth_type Authentication method to retrieve the prefrence of. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 237 | * @return Preference of the @p auth_type. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 238 | */ |
| 239 | int16_t nc_client_ssh_ch_get_auth_pref(NC_SSH_AUTH_TYPE auth_type); |
| 240 | |
| 241 | /** |
| 242 | * @brief Set client Call Home SSH username used for authentication. |
| 243 | * |
| 244 | * @param[in] username Username to use. |
| 245 | * @return 0 on success, -1 on error. |
| 246 | */ |
| 247 | int nc_client_ssh_ch_set_username(const char *username); |
| 248 | |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 249 | /** |
| 250 | * @brief Get client Call Home SSH username used for authentication. |
| 251 | * |
| 252 | * @return Username used. |
| 253 | */ |
| 254 | const char *nc_client_ssh_ch_get_username(void); |
| 255 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 256 | /** @} Client-side Call Home on SSH */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 257 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 258 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 259 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 260 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 261 | |
| 262 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 263 | * @defgroup client_ch_tls Client-side Call Home on TLS |
| 264 | * @ingroup client_ch |
| 265 | * |
| 266 | * @brief TLS settings for the Call Home functionality |
| 267 | * @{ |
| 268 | */ |
| 269 | |
| 270 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 271 | * @brief Add a new client bind and start listening on it for TLS Call Home connections. |
| 272 | * |
| 273 | * @param[in] address IP address to bind to. |
| 274 | * @param[in] port Port to bind to. |
| 275 | * @return 0 on success, -1 on error. |
| 276 | */ |
| 277 | int nc_client_tls_ch_add_bind_listen(const char *address, uint16_t port); |
| 278 | |
| 279 | /** |
| 280 | * @brief Remove a TLS listening client bind. |
| 281 | * |
| 282 | * @param[in] address IP address the socket was bound to. NULL matches all. |
| 283 | * @param[in] port Port the socket was bound to. 0 matches all. |
| 284 | * @return 0 on success, -1 on not found. |
| 285 | */ |
| 286 | int nc_client_tls_ch_del_bind(const char *address, uint16_t port); |
| 287 | |
| 288 | /** |
| 289 | * @brief Set client Call Home authentication identity - a certificate and a private key. |
| 290 | * |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 291 | * @param[in] client_cert Path to the file containing the client certificate. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 292 | * @param[in] client_key Path to the file containing the private key for the @p client_cert. |
| 293 | * If NULL, key is expected to be stored with @p client_cert. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 294 | * @return 0 on success, -1 on error. |
| 295 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 296 | int nc_client_tls_ch_set_cert_key_paths(const char *client_cert, const char *client_key); |
| 297 | |
| 298 | /** |
| 299 | * @brief Get client Call Home authentication identity - a certificate and a private key. |
| 300 | * |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 301 | * @param[out] client_cert Path to the file containing the client certificate. Can be NULL. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 302 | * @param[out] client_key Path to the file containing the private key for the @p client_cert. |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 303 | * Can be NULL. |
| 304 | */ |
| 305 | void nc_client_tls_ch_get_cert_key_paths(const char **client_cert, const char **client_key); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 306 | |
| 307 | /** |
| 308 | * @brief Set client Call Home trusted CA certificates. |
| 309 | * |
| 310 | * @param[in] ca_file Location of the CA certificate file used to verify server certificates. |
| 311 | * For more info, see the documentation for SSL_CTX_load_verify_locations() from OpenSSL. |
| 312 | * @param[in] ca_dir Location of the CA certificates directory used to verify the server certificates. |
| 313 | * For more info, see the documentation for SSL_CTX_load_verify_locations() from OpenSSL. |
| 314 | * @return 0 on success, -1 on error. |
| 315 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 316 | int nc_client_tls_ch_set_trusted_ca_paths(const char *ca_file, const char *ca_dir); |
| 317 | |
| 318 | /** |
| 319 | * @brief Get client Call Home trusted CA certificates. |
| 320 | * |
| 321 | * @param[out] ca_file Location of the CA certificate file used to verify server certificates. |
| 322 | * Can be NULL. |
| 323 | * @param[out] ca_dir Location of the CA certificates directory used to verify the server certificates. |
| 324 | * Can be NULL. |
| 325 | */ |
| 326 | void nc_client_tls_ch_get_trusted_ca_paths(const char **ca_file, const char **ca_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 327 | |
| 328 | /** |
| 329 | * @brief Set client Call Home Certificate Revocation Lists. |
| 330 | * |
| 331 | * @param[in] crl_file Location of the CRL certificate file used to check for revocated certificates. |
| 332 | * @param[in] crl_dir Location of the CRL certificate directory used to check for revocated certificates. |
| 333 | * @return 0 on success, -1 on error. |
| 334 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 335 | int nc_client_tls_ch_set_crl_paths(const char *crl_file, const char *crl_dir); |
| 336 | |
| 337 | /** |
| 338 | * @brief Get client Call Home Certificate Revocation Lists. |
| 339 | * |
| 340 | * @param[out] crl_file Location of the CRL certificate file used to check for revocated certificates. |
| 341 | * Can be NULL. |
| 342 | * @param[out] crl_dir Location of the CRL certificate directory used to check for revocated certificates. |
| 343 | * Can be NULL. |
| 344 | */ |
| 345 | void nc_client_tls_ch_get_crl_paths(const char **crl_file, const char **crl_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 346 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 347 | /** @} Client-side Call Home on TLS */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 348 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 349 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 350 | |
Michal Vasko | c09730e | 2019-01-17 10:07:26 +0100 | [diff] [blame] | 351 | #ifdef __cplusplus |
| 352 | } |
| 353 | #endif |
| 354 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 355 | #endif /* NC_SESSION_CLIENT_CH_H_ */ |