Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file session_server_ch.h |
| 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * \brief libnetconf2 Call Home session server manipulation |
| 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 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_SERVER_CH_H_ |
| 16 | #define NC_SESSION_SERVER_CH_H_ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | #include <libyang/libyang.h> |
| 20 | |
| 21 | #include "session.h" |
| 22 | #include "netconf.h" |
| 23 | |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 24 | #if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS) |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 25 | |
| 26 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 27 | * @defgroup server_ch Server-side Call Home |
| 28 | * @ingroup server |
| 29 | * |
| 30 | * @brief Call Home functionality for server-side applications. |
| 31 | * @{ |
| 32 | */ |
| 33 | |
| 34 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 35 | * @brief Add a new Call Home client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 36 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 37 | * @param[in] name Arbitrary unique client name. |
| 38 | * @param[in] ti Transport protocol to use. |
| 39 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 40 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 41 | int nc_server_ch_add_client(const char *name, NC_TRANSPORT_IMPL ti); |
| 42 | |
| 43 | /** |
| 44 | * @brief Drop any connections, stop connecting and remove a client. |
| 45 | * |
| 46 | * @param[in] name Client name. NULL matches all the clients. |
Michal Vasko | 5905037 | 2016-11-22 14:33:55 +0100 | [diff] [blame] | 47 | * @param[in] ti Client transport protocol. NULL matches any protocol. |
| 48 | * Redundant to set if \p name is set, client names are |
| 49 | * unique disregarding their protocol. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 50 | * @return 0 on success, -1 on not finding any match. |
| 51 | */ |
Michal Vasko | 5905037 | 2016-11-22 14:33:55 +0100 | [diff] [blame] | 52 | int nc_server_ch_del_client(const char *name, NC_TRANSPORT_IMPL ti); |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * @brief Add a new Call Home client endpoint. |
| 56 | * |
| 57 | * @param[in] client_name Existing client name. |
| 58 | * @param[in] endpt_name Arbitrary unique (within the client) endpoint name. |
| 59 | * @return 0 on success, -1 on error. |
| 60 | */ |
| 61 | int nc_server_ch_client_add_endpt(const char *client_name, const char *endpt_name); |
| 62 | |
| 63 | /** |
| 64 | * @brief Remove a Call Home client endpoint. |
| 65 | * |
| 66 | * @param[in] client_name Existing client name. |
| 67 | * @param[in] endpt_name Existing endpoint of \p client_name. NULL matches all endpoints. |
| 68 | * @return 0 on success, -1 on error. |
| 69 | */ |
| 70 | int nc_server_ch_client_del_endpt(const char *client_name, const char *endpt_name); |
| 71 | |
| 72 | /** |
| 73 | * @brief Change Call Home client endpoint listening address. |
| 74 | * |
| 75 | * On error the previous listening socket (if any) is left untouched. |
| 76 | * |
| 77 | * @param[in] client_name Existing Call Home client name. |
| 78 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 79 | * @param[in] address New listening address. |
| 80 | * @return 0 on success, -1 on error. |
| 81 | */ |
| 82 | int nc_server_ch_client_endpt_set_address(const char *client_name, const char *endpt_name, const char *address); |
| 83 | |
| 84 | /** |
| 85 | * @brief Change Call Home client endpoint listening port. |
| 86 | * |
| 87 | * On error the previous listening socket (if any) is left untouched. |
| 88 | * |
| 89 | * @param[in] client_name Existing Call Home client name. |
| 90 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 91 | * @param[in] port New listening port. |
| 92 | * @return 0 on success, -1 on error. |
| 93 | */ |
| 94 | int nc_server_ch_client_endpt_set_port(const char *client_name, const char *endpt_name, uint16_t port); |
| 95 | |
| 96 | /** |
| 97 | * @brief Set Call Home client connection type. |
| 98 | * |
| 99 | * @param[in] client_name Existing Call Home client name. |
| 100 | * @param[in] conn_type Call Home connection type. |
| 101 | * @return 0 on success, -1 on error. |
| 102 | */ |
| 103 | int nc_server_ch_client_set_conn_type(const char *client_name, NC_CH_CONN_TYPE conn_type); |
| 104 | |
| 105 | /** |
| 106 | * @brief Set Call Home client persistent connection idle timeout. |
| 107 | * |
| 108 | * @param[in] client_name Existing Call Home client name. |
| 109 | * @param[in] idle_timeout Call Home persistent idle timeout. |
| 110 | * @return 0 on success, -1 on error. |
| 111 | */ |
| 112 | int nc_server_ch_client_persist_set_idle_timeout(const char *client_name, uint32_t idle_timeout); |
| 113 | |
| 114 | /** |
| 115 | * @brief Set Call Home client persistent connection keep-alive max wait time. |
| 116 | * |
| 117 | * @param[in] client_name Existing Call Home client name. |
| 118 | * @param[in] max_wait Call Home persistent max wait time for keep-alive reply. |
| 119 | * @return 0 on success, -1 on error. |
| 120 | */ |
| 121 | int nc_server_ch_client_persist_set_keep_alive_max_wait(const char *client_name, uint16_t max_wait); |
| 122 | |
| 123 | /** |
| 124 | * @brief Set Call Home client persistent connection keep-alive max attempts. |
| 125 | * |
| 126 | * @param[in] client_name Existing Call Home client name. |
| 127 | * @param[in] max_attempts Call Home persistent keep-alive maximum contact attempts. |
| 128 | * @return 0 on success, -1 on error. |
| 129 | */ |
| 130 | int nc_server_ch_client_persist_set_keep_alive_max_attempts(const char *client_name, uint8_t max_attempts); |
| 131 | |
| 132 | /** |
| 133 | * @brief Set Call Home client periodic connection idle timeout. |
| 134 | * |
| 135 | * @param[in] client_name Existing Call Home client name. |
| 136 | * @param[in] idle_timeout Call Home periodic idle timeout. |
| 137 | * @return 0 on success, -1 on error. |
| 138 | */ |
| 139 | int nc_server_ch_client_period_set_idle_timeout(const char *client_name, uint16_t idle_timeout); |
| 140 | |
| 141 | /** |
| 142 | * @brief Set Call Home client periodic reconnect timeout. |
| 143 | * |
| 144 | * @param[in] client_name Existing Call Home client name. |
| 145 | * @param[in] reconnect_timeout Call Home periodic reconnect timeout. |
| 146 | * @return 0 on success, -1 on error. |
| 147 | */ |
| 148 | int nc_server_ch_client_period_set_reconnect_timeout(const char *client_name, uint16_t reconnect_timeout); |
| 149 | |
| 150 | /** |
| 151 | * @brief Set Call Home client start-with policy. |
| 152 | * |
| 153 | * @param[in] client_name Existing Call Home client name. |
| 154 | * @param[in] start_with Call Home client start-with. |
| 155 | * @return 0 on success, -1 on error. |
| 156 | */ |
| 157 | int nc_server_ch_client_set_start_with(const char *client_name, NC_CH_START_WITH start_with); |
| 158 | |
| 159 | /** |
| 160 | * @brief Set Call Home client overall max attempts. |
| 161 | * |
| 162 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 163 | * @param[in] max_attempts Call Home overall max reconnect attempts. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 164 | * @return 0 on success, -1 on error. |
| 165 | */ |
| 166 | int nc_server_ch_client_set_max_attempts(const char *client_name, uint8_t max_attempts); |
| 167 | |
| 168 | /** |
| 169 | * @brief Establish a Call Home connection with a listening NETCONF client. |
| 170 | * |
| 171 | * @param[in] client_name Existing client name. |
| 172 | * @param[out] session_clb Function that is called for every established session on the client. \p new_session |
| 173 | * pointer is internally discarded afterwards. |
| 174 | * @return 0 if the thread was successfully created, -1 on error. |
| 175 | */ |
| 176 | int nc_connect_ch_client_dispatch(const char *client_name, |
| 177 | void (*session_clb)(const char *client_name, struct nc_session *new_session)); |
| 178 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 179 | /** @} Server-side Call Home */ |
| 180 | |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 181 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
| 182 | |
| 183 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 184 | |
| 185 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 186 | * @defgroup server_ch_ssh Server-side Call Home on SSH |
| 187 | * @ingroup server_ch |
| 188 | * |
| 189 | * @brief SSH settings for the Call Home functionality |
| 190 | * @{ |
| 191 | */ |
| 192 | |
| 193 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 194 | * @brief Add Call Home SSH host keys the server will identify itself with. Only the name is set, the key itself |
| 195 | * wil be retrieved using a callback. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 196 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 197 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 198 | * @param[in] name Arbitrary name of the host key. |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 199 | * @param[in] idx Optional index where to add the key. -1 adds at the end. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 200 | * @return 0 on success, -1 on error. |
| 201 | */ |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 202 | int nc_server_ssh_ch_client_add_hostkey(const char *client_name, const char *name, int16_t idx); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 203 | |
| 204 | /** |
| 205 | * @brief Delete Call Home SSH host keys. Their order is preserved. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 206 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 207 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 208 | * @param[in] name Name of the host key. NULL matches all the keys, but if \p idx != -1 then this must be NULL. |
| 209 | * @param[in] idx Index of the hostkey. -1 matches all indices, but if \p name != NULL then this must be -1. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 210 | * @return 0 on success, -1 on error. |
| 211 | */ |
Michal Vasko | 7d25588 | 2017-02-09 13:35:08 +0100 | [diff] [blame] | 212 | int nc_server_ssh_ch_client_del_hostkey(const char *client_name, const char *name, int16_t idx); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 213 | |
| 214 | /** |
Michal Vasko | fbfe8b6 | 2017-02-14 10:22:30 +0100 | [diff] [blame] | 215 | * @brief Move Call Home SSH host key. |
| 216 | * |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 217 | * @param[in] client_name Exisitng Call Home client name. |
Michal Vasko | fbfe8b6 | 2017-02-14 10:22:30 +0100 | [diff] [blame] | 218 | * @param[in] key_mov Name of the host key that will be moved. |
| 219 | * @param[in] key_after Name of the key that will preceed \p key_mov. NULL if \p key_mov is to be moved at the beginning. |
| 220 | * @return 0 in success, -1 on error. |
| 221 | */ |
| 222 | int nc_server_ssh_ch_client_mov_hostkey(const char *client_name, const char *key_mov, const char *key_after); |
| 223 | |
| 224 | /** |
| 225 | * @brief Modify Call Home SSH host key. |
| 226 | * |
| 227 | * @param[in] endpt_name Exisitng endpoint name. |
| 228 | * @param[in] name Name of an existing host key. |
| 229 | * @param[in] new_name New name of the host key \p name. |
| 230 | * @return 0 in success, -1 on error. |
| 231 | */ |
| 232 | int nc_server_ssh_ch_client_mod_hostkey(const char *endpt_name, const char *name, const char *new_name); |
| 233 | |
| 234 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 235 | * @brief Set Call Home SSH banner the server will send to every client. |
| 236 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 237 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 238 | * @param[in] banner SSH banner. |
| 239 | * @return 0 on success, -1 on error. |
| 240 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 241 | int nc_server_ssh_ch_client_set_banner(const char *client_name, const char *banner); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 242 | |
| 243 | /** |
| 244 | * @brief Set accepted Call Home SSH authentication methods. All (publickey, password, interactive) |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 245 | * are supported by default. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 246 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 247 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 248 | * @param[in] auth_methods Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 249 | * @return 0 on success, -1 on error. |
| 250 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 251 | int nc_server_ssh_ch_client_set_auth_methods(const char *client_name, int auth_methods); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 252 | |
| 253 | /** |
| 254 | * @brief Set Call Home SSH authentication attempts of every client. 3 by default. |
| 255 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 256 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 257 | * @param[in] auth_attempts Failed authentication attempts before a client is dropped. |
| 258 | * @return 0 on success, -1 on error. |
| 259 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 260 | int nc_server_ssh_ch_client_set_auth_attempts(const char *client_name, uint16_t auth_attempts); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 261 | |
| 262 | /** |
| 263 | * @brief Set Call Home SSH authentication timeout. 10 seconds by default. |
| 264 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 265 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 266 | * @param[in] auth_timeout Number of seconds before an unauthenticated client is dropped. |
| 267 | * @return 0 on success, -1 on error. |
| 268 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 269 | int nc_server_ssh_ch_client_set_auth_timeout(const char *client_name, uint16_t auth_timeout); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 270 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 271 | /** @} Server-side Call Home on SSH */ |
| 272 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 273 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 274 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 275 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 276 | |
| 277 | /** |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 278 | * @defgroup server_ch_tls Server-side Call Home on TLS |
| 279 | * @ingroup server_ch |
| 280 | * |
| 281 | * @brief TLS settings for the Call Home functionality |
| 282 | * @{ |
| 283 | */ |
| 284 | |
| 285 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 286 | * @brief Set the server Call Home TLS certificate. Only the name is set, the certificate itself |
| 287 | * wil be retrieved using a callback. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 288 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 289 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 290 | * @param[in] name Arbitrary certificate name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 291 | * @return 0 on success, -1 on error. |
| 292 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 293 | int nc_server_tls_ch_client_set_server_cert(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 294 | |
| 295 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 296 | * @brief Add a Call Home trusted certificate list. Can be both a CA or a client one. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 297 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 298 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 299 | * @param[in] name Arbitary name identifying this certificate list. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 300 | * @return 0 on success, -1 on error. |
| 301 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 302 | int nc_server_tls_ch_client_add_trusted_cert_list(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 303 | |
| 304 | /** |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 305 | * @brief Remove a set Call Home trusted certificate list. CRLs and CTN entries are not affected. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 306 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 307 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 308 | * @param[in] name Name of the certificate list to delete. NULL deletes all the lists. |
| 309 | * @return 0 on success, -1 on not found. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 310 | */ |
Michal Vasko | 4c1fb49 | 2017-01-30 14:31:07 +0100 | [diff] [blame] | 311 | int nc_server_tls_ch_client_del_trusted_cert_list(const char *client_name, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 312 | |
| 313 | /** |
| 314 | * @brief Set trusted Call Home Certificate Authority certificate locations. There |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 315 | * can only be one file and one directory, they are replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 316 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 317 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 318 | * @param[in] ca_file Path to a trusted CA cert store file in PEM format. |
| 319 | * Can be NULL. |
| 320 | * @param[in] ca_dir Path to a trusted CA cert store hashed directory |
| 321 | * (c_rehash utility can be used to create hashes) |
| 322 | * with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 323 | * @return 0 on success, -1 on error. |
| 324 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 325 | int nc_server_tls_ch_client_set_trusted_ca_paths(const char *client_name, const char *ca_file, const char *ca_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 326 | |
| 327 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 328 | * @brief Set Call Home Certificate Revocation List locations. There can only be |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 329 | * one file and one directory, they are replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 330 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 331 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 332 | * @param[in] crl_file Path to a CRL store file in PEM format. Can be NULL. |
| 333 | * @param[in] crl_dir Path to a CRL store hashed directory (c_rehash utility |
| 334 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 335 | * @return 0 on success, -1 on error. |
| 336 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 337 | int nc_server_tls_ch_client_set_crl_paths(const char *client_name, const char *crl_file, const char *crl_dir); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 338 | |
| 339 | /** |
| 340 | * @brief Destroy and clean Call Home CRLs. Call Home certificates, private keys, |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 341 | * and CTN entries are not affected. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 342 | * |
| 343 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 344 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 345 | void nc_server_tls_ch_client_clear_crls(const char *client_name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 346 | |
| 347 | /** |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 348 | * @brief Add a cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 349 | * |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 350 | * It is possible to add an entry step-by-step, specifying first only \p ip and in later calls |
| 351 | * \p fingerprint, \p map_type, and optionally \p name spearately. |
| 352 | * |
Michal Vasko | 50d2a5c | 2017-02-14 10:29:49 +0100 | [diff] [blame] | 353 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 3cf4aaa | 2017-02-01 15:03:36 +0100 | [diff] [blame] | 354 | * @param[in] id Priority of the entry. It must be unique. If already exists, the entry with this id |
| 355 | * is modified. |
| 356 | * @param[in] fingerprint Matching certificate fingerprint. If NULL, kept temporarily unset. |
| 357 | * @param[in] map_type Type of username-certificate mapping. If 0, kept temporarily unset. |
| 358 | * @param[in] name Specific username used only if \p map_type == NC_TLS_CTN_SPECIFED. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 359 | * @return 0 on success, -1 on error. |
| 360 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 361 | int nc_server_tls_ch_client_add_ctn(const char *client_name, uint32_t id, const char *fingerprint, |
| 362 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 363 | |
| 364 | /** |
Michal Vasko | 58c22a2 | 2016-11-23 13:49:53 +0100 | [diff] [blame] | 365 | * @brief Remove a Call Home cert-to-name entry. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 366 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 367 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 368 | * @param[in] id Priority of the entry. -1 matches all the priorities. |
| 369 | * @param[in] fingerprint Fingerprint fo the entry. NULL matches all the fingerprints. |
| 370 | * @param[in] map_type Mapping type of the entry. 0 matches all the mapping types. |
| 371 | * @param[in] name Specific username for the entry. NULL matches all the usernames. |
| 372 | * @return 0 on success, -1 on not finding any match. |
| 373 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 374 | int nc_server_tls_ch_client_del_ctn(const char *client_name, int64_t id, const char *fingerprint, |
| 375 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 376 | |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 377 | /** |
| 378 | * @brief Get a Call Home cert-to-name entry. |
| 379 | * |
| 380 | * If a parameter is NULL, it is ignored. If its dereferenced value is NULL, |
| 381 | * it is filled and returned. If the value is set, it is used as a filter. |
| 382 | * Returns first matching entry. |
| 383 | * |
| 384 | * @param[in] client_name Existing Call Home client name. |
| 385 | * @param[in,out] id Priority of the entry. |
| 386 | * @param[in,out] fingerprint Fingerprint fo the entry. |
| 387 | * @param[in,out] map_type Mapping type of the entry. |
| 388 | * @param[in,out] name Specific username for the entry. |
| 389 | * @return 0 on success, -1 on not finding any match. |
| 390 | */ |
Michal Vasko | f585ac7 | 2016-11-25 15:16:38 +0100 | [diff] [blame] | 391 | int nc_server_tls_ch_client_get_ctn(const char *client_name, uint32_t *id, char **fingerprint, |
| 392 | NC_TLS_CTN_MAPTYPE *map_type, char **name); |
Michal Vasko | df5e6af | 2016-11-23 13:50:56 +0100 | [diff] [blame] | 393 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 394 | /** @} Server-side Call Home on TLS */ |
| 395 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 396 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 397 | |
| 398 | #endif /* NC_SESSION_SERVER_CH_H_ */ |