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 | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2023 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 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 25 | #ifdef NC_ENABLED_SSH_TLS |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 26 | # include <libssh/libssh.h> |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 27 | #endif /* NC_ENABLED_SSH_TLS */ |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 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 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 33 | #ifdef NC_ENABLED_SSH_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 |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 47 | * non-blocking call, -1 for infinite waiting. |
| 48 | * @param[in,out] ctx Optional custom context to use for the session. If not set, a default context is created. |
| 49 | * Any YANG modules not present in the context and supported by the server are loaded using \<get-schema\> |
| 50 | * (if supported) and/or by searching the searchpath (see ::nc_client_set_schema_searchpath()). |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 51 | * @param[out] session New session. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 52 | * @return 1 on success, 0 on timeout, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 53 | */ |
| 54 | int nc_accept_callhome(int timeout, struct ly_ctx *ctx, struct nc_session **session); |
| 55 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 56 | /** @} Client-side Call Home */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 57 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 58 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 59 | * @defgroup client_ch_ssh Client-side Call Home on SSH |
| 60 | * @ingroup client_ch |
| 61 | * |
| 62 | * @brief SSH settings for the Call Home functionality |
| 63 | * @{ |
| 64 | */ |
| 65 | |
| 66 | /** |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 67 | * @brief Set SSH Call Home authentication hostkey check (knownhosts) callback. |
| 68 | * |
| 69 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 70 | * freeing the private data when necessary (the private data can be obtained by |
| 71 | * nc_client_ssh_ch_get_auth_hostkey_check_clb()). |
Michal Vasko | ef112d7 | 2016-02-18 13:28:25 +0100 | [diff] [blame] | 72 | * |
| 73 | * @param[in] auth_hostkey_check Function to call, returns 0 on success, non-zero in error. |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 74 | * If NULL, the default callback is set. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 75 | * @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] | 76 | */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 77 | 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] | 78 | void *priv); |
Michal Vasko | ef112d7 | 2016-02-18 13:28:25 +0100 | [diff] [blame] | 79 | |
| 80 | /** |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 81 | * @brief Get currently set SSH Call Home authentication hostkey check (knownhosts) callback and its private data |
| 82 | * previously set by nc_client_ssh_ch_set_auth_hostkey_check_clb(). |
| 83 | * |
| 84 | * @param[out] auth_hostkey_check Currently set callback, NULL in case of the default callback. |
| 85 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 86 | */ |
| 87 | 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] | 88 | void **priv); |
Michal Vasko | 292c554 | 2023-02-01 14:33:17 +0100 | [diff] [blame] | 89 | |
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 | 94d6140 | 2023-03-16 08:21:52 +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 |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 122 | * authentication name with instruction and echoing prompt. If NULL, the default callback is set. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 123 | * @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] | 124 | */ |
| 125 | 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] | 126 | const char *prompt, int echo, void *priv), |
| 127 | void *priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * @brief Get currently set SSH Call Home interactive authentication callback and its private data |
| 131 | * previously set by nc_client_ssh_ch_set_auth_interactive_clb(). |
| 132 | * |
| 133 | * @param[out] auth_interactive Currently set callback, NULL in case of the default callback. |
| 134 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 135 | */ |
| 136 | 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] | 137 | const char *prompt, int echo, void *priv), |
| 138 | void **priv); |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * @brief Set SSH Call Home publickey authentication encrypted private key passphrase callback. |
| 142 | * |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 143 | * Repetitive calling causes replacing of the previous callback and its private data. Caller is responsible for |
| 144 | * freeing the private data when necessary (the private data can be obtained by |
| 145 | * nc_client_ssh_ch_get_auth_privkey_passphrase_clb()). |
| 146 | * |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 147 | * @param[in] auth_privkey_passphrase Function to call for every question, returns the passphrase for the specific |
| 148 | * private key. |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 149 | * @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] | 150 | */ |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 151 | 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] | 152 | void *priv); |
Radek Krejci | 90a84a2 | 2017-05-25 13:53:00 +0200 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * @brief Get currently set SSH Call Home publickey authentication encrypted private key passphrase callback and its |
| 156 | * private data previously set by nc_client_ssh_ch_set_auth_privkey_passphrase_clb(). |
| 157 | * |
| 158 | * @param[out] auth_privkey_passphrase Currently set callback, NULL in case of the default callback. |
| 159 | * @param[out] priv Currently set (optional) private data to be passed to the callback function. |
| 160 | */ |
| 161 | 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] | 162 | void **priv); |
Michal Vasko | 30e2c87 | 2016-02-18 10:03:21 +0100 | [diff] [blame] | 163 | |
| 164 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 165 | * @brief Add a new client bind and start listening on it for SSH Call Home connections. |
| 166 | * |
| 167 | * @param[in] address IP address to bind to. |
| 168 | * @param[in] port Port to bind to. |
| 169 | * @return 0 on success, -1 on error. |
| 170 | */ |
| 171 | int nc_client_ssh_ch_add_bind_listen(const char *address, uint16_t port); |
| 172 | |
| 173 | /** |
| 174 | * @brief Remove an SSH listening client bind. |
| 175 | * |
| 176 | * @param[in] address IP address the socket was bound to. NULL matches all. |
| 177 | * @param[in] port Port the socket was bound to. 0 matches all. |
| 178 | * @return 0 on success, -1 on not found. |
| 179 | */ |
| 180 | int nc_client_ssh_ch_del_bind(const char *address, uint16_t port); |
| 181 | |
| 182 | /** |
| 183 | * @brief Add an SSH public and private key pair to be used for Call Home client authentication. |
| 184 | * |
| 185 | * Private key can be encrypted, the passphrase will be asked for before using it. |
| 186 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 187 | * @param[in] pub_key Path to the public key. |
| 188 | * @param[in] priv_key Path to the private key. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 189 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 190 | */ |
| 191 | int nc_client_ssh_ch_add_keypair(const char *pub_key, const char *priv_key); |
| 192 | |
| 193 | /** |
| 194 | * @brief Remove an SSH public and private key pair that was used for Call Home client authentication. |
| 195 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 196 | * @param[in] idx Index of the keypair starting with 0. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 197 | * @return 0 on success, -1 on error. |
| 198 | */ |
| 199 | int nc_client_ssh_ch_del_keypair(int idx); |
| 200 | |
| 201 | /** |
| 202 | * @brief Get the number of public an private key pairs set to be used for Call Home client authentication. |
| 203 | * |
| 204 | * @return Keypair count. |
| 205 | */ |
| 206 | int nc_client_ssh_ch_get_keypair_count(void); |
| 207 | |
| 208 | /** |
| 209 | * @brief Get a specific keypair set to be used for Call Home client authentication. |
| 210 | * |
| 211 | * @param[in] idx Index of the specific keypair. |
| 212 | * @param[out] pub_key Path to the public key. |
| 213 | * @param[out] priv_key Path to the private key. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 214 | * @return 0 on success, -1 on error. |
| 215 | */ |
| 216 | int nc_client_ssh_ch_get_keypair(int idx, const char **pub_key, const char **priv_key); |
| 217 | |
| 218 | /** |
| 219 | * @brief Set SSH Call Home authentication method preference. |
| 220 | * |
Radek Krejci | 62aa064 | 2017-05-25 16:33:49 +0200 | [diff] [blame] | 221 | * The default preference is as follows: |
| 222 | * - public key authentication (3) |
| 223 | * - password authentication (2) |
| 224 | * - interactive authentication (1) |
| 225 | * |
| 226 | * @param[in] auth_type Authentication method to modify the preference of. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 227 | * @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] | 228 | */ |
| 229 | void nc_client_ssh_ch_set_auth_pref(NC_SSH_AUTH_TYPE auth_type, int16_t pref); |
| 230 | |
| 231 | /** |
| 232 | * @brief Get SSH Call Home authentication method preference. |
| 233 | * |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 234 | * @param[in] auth_type Authentication method to retrieve the prefrence of. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 235 | * @return Preference of the @p auth_type. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 236 | */ |
| 237 | int16_t nc_client_ssh_ch_get_auth_pref(NC_SSH_AUTH_TYPE auth_type); |
| 238 | |
| 239 | /** |
| 240 | * @brief Set client Call Home SSH username used for authentication. |
| 241 | * |
| 242 | * @param[in] username Username to use. |
| 243 | * @return 0 on success, -1 on error. |
| 244 | */ |
| 245 | int nc_client_ssh_ch_set_username(const char *username); |
| 246 | |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 247 | /** |
| 248 | * @brief Get client Call Home SSH username used for authentication. |
| 249 | * |
| 250 | * @return Username used. |
| 251 | */ |
| 252 | const char *nc_client_ssh_ch_get_username(void); |
| 253 | |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 254 | /** @} Client-side Call Home on SSH */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 255 | |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 256 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 257 | * @defgroup client_ch_tls Client-side Call Home on TLS |
| 258 | * @ingroup client_ch |
| 259 | * |
| 260 | * @brief TLS settings for the Call Home functionality |
| 261 | * @{ |
| 262 | */ |
| 263 | |
| 264 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 265 | * @brief Add a new client bind and start listening on it for TLS Call Home connections. |
| 266 | * |
| 267 | * @param[in] address IP address to bind to. |
| 268 | * @param[in] port Port to bind to. |
| 269 | * @return 0 on success, -1 on error. |
| 270 | */ |
| 271 | int nc_client_tls_ch_add_bind_listen(const char *address, uint16_t port); |
| 272 | |
| 273 | /** |
Michal Vasko | 9d4cca5 | 2022-09-07 11:19:57 +0200 | [diff] [blame] | 274 | * @brief Add a new client bind and start listening on it for TLS Call Home connections coming from the specified hostname. |
| 275 | * |
| 276 | * @param[in] address IP address to bind to. |
| 277 | * @param[in] port Port to bind to. |
Michal Vasko | b8f1fa1 | 2022-09-07 11:47:42 +0200 | [diff] [blame] | 278 | * @param[in] hostname Expected server hostname, verified by TLS when connecting to it. If NULL, the check is skipped. |
Michal Vasko | 9d4cca5 | 2022-09-07 11:19:57 +0200 | [diff] [blame] | 279 | * @return 0 on success, -1 on error. |
| 280 | */ |
| 281 | int nc_client_tls_ch_add_bind_hostname_listen(const char *address, uint16_t port, const char *hostname); |
| 282 | |
| 283 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 284 | * @brief Remove a TLS listening client bind. |
| 285 | * |
| 286 | * @param[in] address IP address the socket was bound to. NULL matches all. |
| 287 | * @param[in] port Port the socket was bound to. 0 matches all. |
| 288 | * @return 0 on success, -1 on not found. |
| 289 | */ |
| 290 | int nc_client_tls_ch_del_bind(const char *address, uint16_t port); |
| 291 | |
| 292 | /** |
| 293 | * @brief Set client Call Home authentication identity - a certificate and a private key. |
| 294 | * |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 295 | * @param[in] client_cert Path to the file containing the client certificate. |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 296 | * @param[in] client_key Path to the file containing the private key for the @p client_cert. |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 297 | * If NULL, key is expected to be stored with @p client_cert. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 298 | * @return 0 on success, -1 on error. |
| 299 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 300 | int nc_client_tls_ch_set_cert_key_paths(const char *client_cert, const char *client_key); |
| 301 | |
| 302 | /** |
| 303 | * @brief Get client Call Home authentication identity - a certificate and a private key. |
| 304 | * |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 305 | * @param[out] client_cert Path to the file containing the client certificate. Can be NULL. |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 306 | * @param[out] client_key Path to the file containing the private key for the @p client_cert. Can be NULL. |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 307 | */ |
| 308 | 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] | 309 | |
| 310 | /** |
| 311 | * @brief Set client Call Home trusted CA certificates. |
| 312 | * |
| 313 | * @param[in] ca_file Location of the CA certificate file used to verify server certificates. |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 314 | * For more info, see the documentation for SSL_CTX_load_verify_locations() from OpenSSL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 315 | * @param[in] ca_dir Location of the CA certificates directory used to verify the server certificates. |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 316 | * For more info, see the documentation for SSL_CTX_load_verify_locations() from OpenSSL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 317 | * @return 0 on success, -1 on error. |
| 318 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 319 | int nc_client_tls_ch_set_trusted_ca_paths(const char *ca_file, const char *ca_dir); |
| 320 | |
| 321 | /** |
| 322 | * @brief Get client Call Home trusted CA certificates. |
| 323 | * |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 324 | * @param[out] ca_file Location of the CA certificate file used to verify server certificates. Can be NULL. |
| 325 | * @param[out] ca_dir Location of the CA certificates directory used to verify the server certificates. Can be NULL. |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 326 | */ |
| 327 | 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] | 328 | |
| 329 | /** |
| 330 | * @brief Set client Call Home Certificate Revocation Lists. |
| 331 | * |
| 332 | * @param[in] crl_file Location of the CRL certificate file used to check for revocated certificates. |
| 333 | * @param[in] crl_dir Location of the CRL certificate directory used to check for revocated certificates. |
| 334 | * @return 0 on success, -1 on error. |
| 335 | */ |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 336 | int nc_client_tls_ch_set_crl_paths(const char *crl_file, const char *crl_dir); |
| 337 | |
| 338 | /** |
| 339 | * @brief Get client Call Home Certificate Revocation Lists. |
| 340 | * |
Michal Vasko | 94d6140 | 2023-03-16 08:21:52 +0100 | [diff] [blame] | 341 | * @param[out] crl_file Location of the CRL certificate file used to check for revocated certificates. Can be NULL. |
| 342 | * @param[out] crl_dir Location of the CRL certificate directory used to check for revocated certificates. Can be NULL. |
Michal Vasko | e22c673 | 2016-01-29 11:03:02 +0100 | [diff] [blame] | 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 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 348 | #endif /* NC_ENABLED_SSH_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_ */ |