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