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 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 27 | * @brief Add a new Call Home client. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 28 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 29 | * @param[in] name Arbitrary unique client name. |
| 30 | * @param[in] ti Transport protocol to use. |
| 31 | * @return 0 on success, -1 on error. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 32 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 33 | int nc_server_ch_add_client(const char *name, NC_TRANSPORT_IMPL ti); |
| 34 | |
| 35 | /** |
| 36 | * @brief Drop any connections, stop connecting and remove a client. |
| 37 | * |
| 38 | * @param[in] name Client name. NULL matches all the clients. |
| 39 | * @return 0 on success, -1 on not finding any match. |
| 40 | */ |
| 41 | int nc_server_ch_del_client(const char *name); |
| 42 | |
| 43 | /** |
| 44 | * @brief Add a new Call Home client endpoint. |
| 45 | * |
| 46 | * @param[in] client_name Existing client name. |
| 47 | * @param[in] endpt_name Arbitrary unique (within the client) endpoint name. |
| 48 | * @return 0 on success, -1 on error. |
| 49 | */ |
| 50 | int nc_server_ch_client_add_endpt(const char *client_name, const char *endpt_name); |
| 51 | |
| 52 | /** |
| 53 | * @brief Remove a Call Home client endpoint. |
| 54 | * |
| 55 | * @param[in] client_name Existing client name. |
| 56 | * @param[in] endpt_name Existing endpoint of \p client_name. NULL matches all endpoints. |
| 57 | * @return 0 on success, -1 on error. |
| 58 | */ |
| 59 | int nc_server_ch_client_del_endpt(const char *client_name, const char *endpt_name); |
| 60 | |
| 61 | /** |
| 62 | * @brief Change Call Home client endpoint listening address. |
| 63 | * |
| 64 | * On error the previous listening socket (if any) is left untouched. |
| 65 | * |
| 66 | * @param[in] client_name Existing Call Home client name. |
| 67 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 68 | * @param[in] address New listening address. |
| 69 | * @return 0 on success, -1 on error. |
| 70 | */ |
| 71 | int nc_server_ch_client_endpt_set_address(const char *client_name, const char *endpt_name, const char *address); |
| 72 | |
| 73 | /** |
| 74 | * @brief Change Call Home client endpoint listening port. |
| 75 | * |
| 76 | * On error the previous listening socket (if any) is left untouched. |
| 77 | * |
| 78 | * @param[in] client_name Existing Call Home client name. |
| 79 | * @param[in] endpt_name Existing endpoint name of \p client_name. |
| 80 | * @param[in] port New listening port. |
| 81 | * @return 0 on success, -1 on error. |
| 82 | */ |
| 83 | int nc_server_ch_client_endpt_set_port(const char *client_name, const char *endpt_name, uint16_t port); |
| 84 | |
| 85 | /** |
| 86 | * @brief Set Call Home client connection type. |
| 87 | * |
| 88 | * @param[in] client_name Existing Call Home client name. |
| 89 | * @param[in] conn_type Call Home connection type. |
| 90 | * @return 0 on success, -1 on error. |
| 91 | */ |
| 92 | int nc_server_ch_client_set_conn_type(const char *client_name, NC_CH_CONN_TYPE conn_type); |
| 93 | |
| 94 | /** |
| 95 | * @brief Set Call Home client persistent connection idle timeout. |
| 96 | * |
| 97 | * @param[in] client_name Existing Call Home client name. |
| 98 | * @param[in] idle_timeout Call Home persistent idle timeout. |
| 99 | * @return 0 on success, -1 on error. |
| 100 | */ |
| 101 | int nc_server_ch_client_persist_set_idle_timeout(const char *client_name, uint32_t idle_timeout); |
| 102 | |
| 103 | /** |
| 104 | * @brief Set Call Home client persistent connection keep-alive max wait time. |
| 105 | * |
| 106 | * @param[in] client_name Existing Call Home client name. |
| 107 | * @param[in] max_wait Call Home persistent max wait time for keep-alive reply. |
| 108 | * @return 0 on success, -1 on error. |
| 109 | */ |
| 110 | int nc_server_ch_client_persist_set_keep_alive_max_wait(const char *client_name, uint16_t max_wait); |
| 111 | |
| 112 | /** |
| 113 | * @brief Set Call Home client persistent connection keep-alive max attempts. |
| 114 | * |
| 115 | * @param[in] client_name Existing Call Home client name. |
| 116 | * @param[in] max_attempts Call Home persistent keep-alive maximum contact attempts. |
| 117 | * @return 0 on success, -1 on error. |
| 118 | */ |
| 119 | int nc_server_ch_client_persist_set_keep_alive_max_attempts(const char *client_name, uint8_t max_attempts); |
| 120 | |
| 121 | /** |
| 122 | * @brief Set Call Home client periodic connection idle timeout. |
| 123 | * |
| 124 | * @param[in] client_name Existing Call Home client name. |
| 125 | * @param[in] idle_timeout Call Home periodic idle timeout. |
| 126 | * @return 0 on success, -1 on error. |
| 127 | */ |
| 128 | int nc_server_ch_client_period_set_idle_timeout(const char *client_name, uint16_t idle_timeout); |
| 129 | |
| 130 | /** |
| 131 | * @brief Set Call Home client periodic reconnect timeout. |
| 132 | * |
| 133 | * @param[in] client_name Existing Call Home client name. |
| 134 | * @param[in] reconnect_timeout Call Home periodic reconnect timeout. |
| 135 | * @return 0 on success, -1 on error. |
| 136 | */ |
| 137 | int nc_server_ch_client_period_set_reconnect_timeout(const char *client_name, uint16_t reconnect_timeout); |
| 138 | |
| 139 | /** |
| 140 | * @brief Set Call Home client start-with policy. |
| 141 | * |
| 142 | * @param[in] client_name Existing Call Home client name. |
| 143 | * @param[in] start_with Call Home client start-with. |
| 144 | * @return 0 on success, -1 on error. |
| 145 | */ |
| 146 | int nc_server_ch_client_set_start_with(const char *client_name, NC_CH_START_WITH start_with); |
| 147 | |
| 148 | /** |
| 149 | * @brief Set Call Home client overall max attempts. |
| 150 | * |
| 151 | * @param[in] client_name Existing Call Home client name. |
| 152 | * @param[in] conn_type Call Home overall max reconnect attempts. |
| 153 | * @return 0 on success, -1 on error. |
| 154 | */ |
| 155 | int nc_server_ch_client_set_max_attempts(const char *client_name, uint8_t max_attempts); |
| 156 | |
| 157 | /** |
| 158 | * @brief Establish a Call Home connection with a listening NETCONF client. |
| 159 | * |
| 160 | * @param[in] client_name Existing client name. |
| 161 | * @param[out] session_clb Function that is called for every established session on the client. \p new_session |
| 162 | * pointer is internally discarded afterwards. |
| 163 | * @return 0 if the thread was successfully created, -1 on error. |
| 164 | */ |
| 165 | int nc_connect_ch_client_dispatch(const char *client_name, |
| 166 | void (*session_clb)(const char *client_name, struct nc_session *new_session)); |
| 167 | |
| 168 | #endif /* NC_ENABLED_SSH || NC_ENABLED_TLS */ |
| 169 | |
| 170 | #ifdef NC_ENABLED_SSH |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 171 | |
| 172 | /** |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 173 | * @brief Add Call Home SSH host keys the server will identify itself with. Any RSA, DSA, and |
| 174 | * ECDSA keys can be added. However, a maximum of one key of each type will be used |
| 175 | * during SSH authentication, later keys replacing earlier ones. |
| 176 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 177 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | d6829ce | 2016-09-22 09:45:13 +0200 | [diff] [blame] | 178 | * @param[in] privkey_path Path to a private key. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 179 | * @return 0 on success, -1 on error. |
| 180 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 181 | int nc_server_ssh_ch_client_add_hostkey(const char *client_name, const char *privkey_path); |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 182 | |
| 183 | /** |
| 184 | * @brief Delete Call Home SSH host keys. Their order is preserved. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 185 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 186 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | d6829ce | 2016-09-22 09:45:13 +0200 | [diff] [blame] | 187 | * @param[in] privkey_path Path to a private key. NULL matches all the keys. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 188 | * @return 0 on success, -1 on error. |
| 189 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 190 | int nc_server_ssh_ch_client_del_hostkey(const char *client_name, const char *privkey_path); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * @brief Set Call Home SSH banner the server will send to every client. |
| 194 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 195 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 196 | * @param[in] banner SSH banner. |
| 197 | * @return 0 on success, -1 on error. |
| 198 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 199 | 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] | 200 | |
| 201 | /** |
| 202 | * @brief Set accepted Call Home SSH authentication methods. All (publickey, password, interactive) |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 203 | * are supported by default. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 204 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 205 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 206 | * @param[in] auth_methods Accepted authentication methods bit field of NC_SSH_AUTH_TYPE. |
| 207 | * @return 0 on success, -1 on error. |
| 208 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 209 | 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] | 210 | |
| 211 | /** |
| 212 | * @brief Set Call Home SSH authentication attempts of every client. 3 by default. |
| 213 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 214 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 215 | * @param[in] auth_attempts Failed authentication attempts before a client is dropped. |
| 216 | * @return 0 on success, -1 on error. |
| 217 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 218 | 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] | 219 | |
| 220 | /** |
| 221 | * @brief Set Call Home SSH authentication timeout. 10 seconds by default. |
| 222 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 223 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 224 | * @param[in] auth_timeout Number of seconds before an unauthenticated client is dropped. |
| 225 | * @return 0 on success, -1 on error. |
| 226 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 227 | 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] | 228 | |
| 229 | /** |
| 230 | * @brief Add an authorized Call Home client SSH public key. This public key can be used for |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 231 | * publickey authentication afterwards. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 232 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 233 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 234 | * @param[in] pubkey_path Path to the public key. |
| 235 | * @param[in] username Username that the client with the public key must use. |
| 236 | * @return 0 on success, -1 on error. |
| 237 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 238 | int nc_server_ssh_ch_client_add_authkey(const char *client_name, const char *pubkey_path, const char *username); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 239 | |
| 240 | /** |
| 241 | * @brief Remove an authorized Call Home client SSH public key. |
| 242 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 243 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 244 | * @param[in] pubkey_path Path to an authorized public key. NULL matches all the keys. |
| 245 | * @param[in] username Username for an authorized public key. NULL matches all the usernames. |
| 246 | * @return 0 on success, -1 on not finding any match. |
| 247 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 248 | int nc_server_ssh_ch_client_del_authkey(const char *client_name, const char *pubkey_path, const char *username); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 249 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 250 | #endif /* NC_ENABLED_SSH */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 251 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 252 | #ifdef NC_ENABLED_TLS |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 253 | |
| 254 | /** |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 255 | * @brief Set server Call Home TLS certificate. Alternative to nc_tls_server_set_cert_path(). |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 256 | * There can only be one certificate for each key type, it is replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 257 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 258 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 259 | * @param[in] cert Base64-encoded certificate in ASN.1 DER encoding. |
| 260 | * @return 0 on success, -1 on error. |
| 261 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 262 | int nc_server_tls_ch_client_set_cert(const char *client_name, const char *cert); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 263 | |
| 264 | /** |
| 265 | * @brief Set server Call Home TLS certificate. Alternative to nc_tls_server_set_cert(). |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 266 | * There can only be one certificate for each key type, it is replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 267 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 268 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 269 | * @param[in] cert_path Path to a certificate file in PEM format. |
| 270 | * @return 0 on success, -1 on error. |
| 271 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 272 | int nc_server_tls_ch_client_set_cert_path(const char *client_name, const char *cert_path); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 273 | |
| 274 | /** |
| 275 | * @brief Set server Call Home TLS private key matching the certificate. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 276 | * Alternative to nc_server_tls_ch_client_set_key_path(). |
| 277 | * There can only be one of every key type, it is replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 278 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 279 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 280 | * @param[in] privkey Base64-encoded certificate in ASN.1 DER encoding. |
| 281 | * @param[in] is_rsa Whether \p privkey are the data of an RSA (1) or DSA (0) key. |
| 282 | * @return 0 on success, -1 on error. |
| 283 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 284 | int nc_server_tls_ch_client_set_key(const char *client_name, const char *privkey, int is_rsa); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 285 | |
| 286 | /** |
| 287 | * @brief Set server Call Home TLS private key matching the certificate. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 288 | * Alternative to nc_server_tls_ch_client_set_key(). |
| 289 | * There can only be one of every key type, it is replaced if already set. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 290 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 291 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 292 | * @param[in] privkey_path Path to a private key file in PEM format. |
| 293 | * @return 0 on success, -1 on error. |
| 294 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 295 | int nc_server_tls_ch_client_set_key_path(const char *client_name, const char *privkey_path); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 296 | |
| 297 | /** |
| 298 | * @brief Add a Call Home trusted certificate. Can be both a CA or a client one. |
| 299 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 300 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 301 | * @param[in] cert_name Arbitary name identifying this certificate. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 302 | * @param[in] cert Base64-enocded certificate in ASN.1 DER encoding. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 303 | * @return 0 on success, -1 on error. |
| 304 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 305 | int nc_server_tls_ch_client_add_trusted_cert(const char *client_name, const char *cert_name, const char *cert); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 306 | |
| 307 | /** |
| 308 | * @brief Add a Call Home trusted certificate. Can be both a CA or a client one. |
| 309 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 310 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 311 | * @param[in] cert_name Arbitary name identifying this certificate. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 312 | * @param[in] cert_path Path to a trusted certificate file in PEM format. |
| 313 | * @return 0 on success, -1 on error. |
| 314 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 315 | int nc_server_tls_ch_client_add_trusted_cert_path(const char *client_name, const char *cert_name, const char *cert_path); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 316 | |
| 317 | /** |
| 318 | * @brief Set trusted Call Home Certificate Authority certificate locations. There |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 319 | * 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] | 320 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 321 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 322 | * @param[in] ca_file Path to a trusted CA cert store file in PEM format. |
| 323 | * Can be NULL. |
| 324 | * @param[in] ca_dir Path to a trusted CA cert store hashed directory |
| 325 | * (c_rehash utility can be used to create hashes) |
| 326 | * with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 327 | * @return 0 on success, -1 on error. |
| 328 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 329 | 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] | 330 | |
| 331 | /** |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 332 | * @brief Remove a set Call Home trusted certificate. |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 333 | * CRLs and CTN entries are not affected. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 334 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 335 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | e2713da | 2016-08-22 16:06:40 +0200 | [diff] [blame] | 336 | * @param[in] cert_name Name of the certificate to delete. NULL deletes all the certificates. |
| 337 | * @return 0 on success, -1 on not found. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 338 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 339 | int nc_server_tls_ch_client_del_trusted_cert(const char *client_name, const char *cert_name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 340 | |
| 341 | /** |
| 342 | * @brief Set Call Home Certificate Revocation List locations. There can only be |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 343 | * one file and one directory, they are replaced if already set. |
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 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | b34b3e8 | 2016-02-26 15:04:58 +0100 | [diff] [blame] | 346 | * @param[in] crl_file Path to a CRL store file in PEM format. Can be NULL. |
| 347 | * @param[in] crl_dir Path to a CRL store hashed directory (c_rehash utility |
| 348 | * can be used to create hashes) with PEM files. Can be NULL. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 349 | * @return 0 on success, -1 on error. |
| 350 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 351 | 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] | 352 | |
| 353 | /** |
| 354 | * @brief Destroy and clean Call Home CRLs. Call Home certificates, private keys, |
Michal Vasko | f0537d8 | 2016-01-29 14:42:38 +0100 | [diff] [blame] | 355 | * and CTN entries are not affected. |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 356 | * |
| 357 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 358 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 359 | void nc_server_tls_ch_client_clear_crls(const char *client_name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 360 | |
| 361 | /** |
| 362 | * @brief Add a Call Home Cert-to-name entry. |
| 363 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 364 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 365 | * @param[in] id Priority of the entry. |
| 366 | * @param[in] fingerprint Matching certificate fingerprint. |
| 367 | * @param[in] map_type Type of username-certificate mapping. |
| 368 | * @param[in] name Specific username if \p map_type == NC_TLS_CTN_SPECIFED. Must be NULL otherwise. |
| 369 | * @return 0 on success, -1 on error. |
| 370 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 371 | int nc_server_tls_ch_client_add_ctn(const char *client_name, uint32_t id, const char *fingerprint, |
| 372 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 373 | |
| 374 | /** |
| 375 | * @brief Remove a Call Home Cert-to-name entry. |
| 376 | * |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 377 | * @param[in] client_name Existing Call Home client name. |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 378 | * @param[in] id Priority of the entry. -1 matches all the priorities. |
| 379 | * @param[in] fingerprint Fingerprint fo the entry. NULL matches all the fingerprints. |
| 380 | * @param[in] map_type Mapping type of the entry. 0 matches all the mapping types. |
| 381 | * @param[in] name Specific username for the entry. NULL matches all the usernames. |
| 382 | * @return 0 on success, -1 on not finding any match. |
| 383 | */ |
Michal Vasko | 2e6defd | 2016-10-07 15:48:15 +0200 | [diff] [blame] | 384 | int nc_server_tls_ch_client_del_ctn(const char *client_name, int64_t id, const char *fingerprint, |
| 385 | NC_TLS_CTN_MAPTYPE map_type, const char *name); |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 386 | |
Radek Krejci | 53691be | 2016-02-22 13:58:37 +0100 | [diff] [blame] | 387 | #endif /* NC_ENABLED_TLS */ |
Michal Vasko | 45f298f | 2016-01-29 10:26:26 +0100 | [diff] [blame] | 388 | |
| 389 | #endif /* NC_SESSION_SERVER_CH_H_ */ |