roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1 | /** |
roman | e028ef9 | 2023-02-24 16:33:08 +0100 | [diff] [blame] | 2 | * @file server_config.h |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 3 | * @author Roman Janota <janota@cesnet.cz> |
| 4 | * @brief libnetconf2 server configuration |
| 5 | * |
| 6 | * @copyright |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 7 | * Copyright (c) 2023 CESNET, z.s.p.o. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 8 | * |
| 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 |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
| 15 | |
| 16 | #ifndef NC_CONFIG_SERVER_H_ |
| 17 | #define NC_CONFIG_SERVER_H_ |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 23 | #include <stdarg.h> |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 24 | #include <stdint.h> |
| 25 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 26 | #include <libyang/libyang.h> |
| 27 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 28 | #include "session.h" |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 29 | |
| 30 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 31 | * @defgroup server_config Server Configuration |
| 32 | * @ingroup server |
| 33 | * |
| 34 | * @brief Server-side configuration creation and application |
| 35 | * @{ |
| 36 | */ |
| 37 | |
| 38 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 39 | * @brief Configure server based on the given diff data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 40 | * |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 41 | * Expected data are a validated instance of a ietf-netconf-server YANG data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 42 | * The data must be in the diff format and supported operations are: create, replace, |
| 43 | * delete and none. Context must already have implemented the required modules, see |
| 44 | * ::nc_config_load_modules(). |
| 45 | * |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 46 | * @param[in] diff ietf-netconf-server YANG diff data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 47 | * @return 0 on success, 1 on error. |
| 48 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 49 | int nc_server_config_setup_diff(const struct lyd_node *diff); |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 50 | |
| 51 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 52 | * @brief Configure server based on the given data. |
| 53 | * |
| 54 | * Expected data is a validated instance of a ietf-netconf-server YANG data. |
| 55 | * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted |
| 56 | * and just the given data will all be applied. |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 57 | * The data must not contain any operation attribute, see ::nc_config_setup_diff() which works with diff. |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 58 | * Context must already have implemented the required modules, see * ::nc_config_load_modules(). |
| 59 | * |
| 60 | * @param[in] data ietf-netconf-server YANG data. |
| 61 | * @return 0 on success, 1 on error. |
| 62 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 63 | int nc_server_config_setup_data(const struct lyd_node *data); |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 64 | |
| 65 | /** |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 66 | * @brief Configure server based on the given ietf-netconf-server YANG data. |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 67 | * Wrapper around ::nc_config_setup_server_data() hiding work with parsing the data. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 68 | * |
| 69 | * @param[in] ctx libyang context. |
| 70 | * @param[in] path Path to the file with YANG data in XML format. |
| 71 | * @return 0 on success, 1 on error. |
| 72 | */ |
| 73 | int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path); |
| 74 | |
| 75 | /** |
| 76 | * @brief Implements all the required modules and their features in the context. |
| 77 | * Needs to be called before any other configuration functions. |
| 78 | * |
| 79 | * If ctx is : |
| 80 | * - NULL: a new context will be created and if the call is successful you have to free it, |
| 81 | * - non NULL: modules will simply be implemented. |
| 82 | * |
| 83 | * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types, |
| 84 | * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs, |
| 85 | * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore, |
| 86 | * ietf-tls-server and libnetconf2-netconf-server. |
| 87 | * |
| 88 | * @param[in, out] ctx Optional context in which the modules will be implemented. Created if ctx is null. |
| 89 | * @return 0 on success, 1 on error. |
| 90 | */ |
| 91 | int nc_server_config_load_modules(struct ly_ctx **ctx); |
| 92 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 93 | #ifdef NC_ENABLED_SSH_TLS |
| 94 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 95 | /** |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 96 | * @brief Creates new YANG configuration data nodes for a local-address and local-port. |
| 97 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 98 | * @param[in] ctx libyang context. |
| 99 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 100 | * @param[in] transport Either SSH or TLS transport for the given endpoint. |
| 101 | * @param[in] address New listening address. |
| 102 | * @param[in] port New listening port. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 103 | * If an endpoint with this identifier already exists, its address and port will be overriden. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 104 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 105 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 106 | * @return 0 on success, non-zero otherwise. |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 107 | */ |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 108 | int nc_server_config_new_address_port(const struct ly_ctx *ctx, const char *endpt_name, NC_TRANSPORT_IMPL transport, |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 109 | const char *address, uint16_t port, struct lyd_node **config); |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 110 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 111 | #endif /* NC_ENABLED_SSH_TLS */ |
| 112 | |
| 113 | /** |
| 114 | * @brief Deletes an endpoint from the YANG data. |
| 115 | * |
| 116 | * @param[in] endpt_name Optional identifier of an endpoint to be deleted. |
| 117 | * If NULL, all of the endpoints will be deleted. |
| 118 | * @param[in,out] config Configuration YANG data tree. |
| 119 | * @return 0 on success, non-zero otherwise. |
| 120 | */ |
| 121 | int nc_server_config_new_del_endpt(const char *endpt_name, struct lyd_node **config); |
| 122 | |
| 123 | #ifdef NC_ENABLED_SSH_TLS |
| 124 | |
| 125 | /** |
| 126 | * @brief Creates new YANG data nodes for an asymmetric key in the keystore. |
| 127 | * |
| 128 | * @param[in] ctx libyang context. |
| 129 | * @param[in] name Name of the asymmetric key pair. |
| 130 | * This name is used to reference the key pair. |
| 131 | * @param[in] privkey_path Path to a private key file. |
| 132 | * @param[in] pubkey_path Optional path a public key file. |
| 133 | * If not supplied, it will be generated from the private key. |
| 134 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 135 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 136 | * @return 0 on success, non-zero otherwise. |
| 137 | */ |
| 138 | int nc_server_config_new_keystore_asym_key(const struct ly_ctx *ctx, const char *name, const char *privkey_path, |
| 139 | const char *pubkey_path, struct lyd_node **config); |
| 140 | |
| 141 | /** |
| 142 | * @brief Deletes a keystore's asymmetric key from the YANG data. |
| 143 | * |
| 144 | * @param[in] name Optional identifier of the asymmetric key to be deleted. |
| 145 | * If NULL, all of the asymmetric keys in the keystore will be deleted. |
| 146 | * @param[in,out] config Configuration YANG data tree. |
| 147 | * @return 0 on success, non-zero otherwise. |
| 148 | */ |
| 149 | int nc_server_config_new_del_keystore_asym_key(const char *name, struct lyd_node **config); |
| 150 | |
| 151 | /** |
| 152 | * @brief Creates new YANG data nodes for a public key in the truststore. |
| 153 | * |
| 154 | * @param[in] ctx libyang context. |
| 155 | * @param[in] bag_name Arbitrary identifier of the public key bag. |
| 156 | * This name is used to reference the public keys in the bag. |
| 157 | * If a public key bag with this name already exists, its contents will be changed. |
| 158 | * @param[in] pubkey_name Arbitrary identifier of the public key. |
| 159 | * If a public key with this name already exists, its contents will be changed. |
| 160 | * @param[in] pubkey_path Path to a file containing a public key. |
| 161 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 162 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 163 | * @return 0 on success, non-zero otherwise. |
| 164 | */ |
| 165 | int nc_server_config_new_truststore_pubkey(const struct ly_ctx *ctx, const char *bag_name, const char *pubkey_name, |
| 166 | const char *pubkey_path, struct lyd_node **config); |
| 167 | |
| 168 | /** |
| 169 | * @brief Deletes a truststore's public key from the YANG data. |
| 170 | * |
| 171 | * @param[in] bag_name Identifier of an existing public key bag. |
| 172 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 173 | * If NULL, all of the public keys in the given bag will be deleted. |
| 174 | * @param[in,out] config Configuration YANG data tree. |
| 175 | * @return 0 on success, non-zero otherwise. |
| 176 | */ |
| 177 | int nc_server_config_new_del_truststore_pubkey(const char *bag_name, const char *pubkey_name, struct lyd_node **config); |
| 178 | |
| 179 | /** |
| 180 | * @} |
| 181 | */ |
| 182 | |
| 183 | /** |
| 184 | * @defgroup server_config_ssh SSH Server Configuration |
| 185 | * @ingroup server_config |
| 186 | * |
| 187 | * @brief SSH server configuration creation and deletion |
| 188 | * @{ |
| 189 | */ |
| 190 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 191 | /** |
| 192 | * @brief Creates new YANG configuration data nodes for a hostkey. |
| 193 | * |
| 194 | * @param[in] ctx libyang context. |
| 195 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 196 | * If an endpoint with this identifier already exists, its hostkey might be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 197 | * @param[in] hostkey_name Arbitrary identifier of the hostkey. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 198 | * If a hostkey with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 199 | * @param[in] privkey_path Path to a file containing a private key. |
| 200 | * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported. |
| 201 | * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be |
| 202 | * generated from the private key. |
| 203 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 204 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 205 | * @return 0 on success, non-zero otherwise. |
| 206 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 207 | int nc_server_config_new_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name, |
| 208 | const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
| 209 | |
| 210 | /** |
| 211 | * @brief Deletes a hostkey from the YANG data. |
| 212 | * |
| 213 | * @param[in] ctx libyang context. |
| 214 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 215 | * @param[in] hostkey_name Optional identifier of the hostkey to be deleted. |
| 216 | * If NULL, all of the hostkeys on this endpoint will be deleted. |
| 217 | * @param[in,out] config Configuration YANG data tree. |
| 218 | * @return 0 on success, non-zero otherwise. |
| 219 | */ |
| 220 | int nc_server_config_new_ssh_del_hostkey(const struct ly_ctx *ctx, const char *endpt_name, |
| 221 | const char *hostkey_name, struct lyd_node **config); |
| 222 | |
| 223 | /** |
| 224 | * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore. |
| 225 | * |
| 226 | * This asymmetric key pair will be used as the SSH hostkey. |
| 227 | * |
| 228 | * @param[in] ctx libyang context. |
| 229 | * @param[in] endpt_name Arbitrary identifier of an endpoint. |
| 230 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 231 | * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey. |
| 232 | * If an endpoint's hostkey with this identifier already exists, its contents will be changed. |
| 233 | * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey. |
| 234 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 235 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 236 | * @return 0 on success, non-zero otherwise. |
| 237 | */ |
| 238 | int nc_server_config_new_ssh_keystore_reference(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name, |
| 239 | const char *keystore_reference, struct lyd_node **config); |
| 240 | |
| 241 | /** |
| 242 | * @brief Deletes a keystore reference from the YANG data. |
| 243 | * |
| 244 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 245 | * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint. |
| 246 | * @param[in,out] config Configuration YANG data tree. |
| 247 | * @return 0 on success, non-zero otherwise. |
| 248 | */ |
| 249 | int nc_server_config_new_ssh_del_keystore_reference(const char *endpt_name, const char *hostkey_name, |
| 250 | struct lyd_node **config); |
| 251 | |
| 252 | /** |
| 253 | * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method. |
| 254 | * |
| 255 | * @param[in] ctx libyang context. |
| 256 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 257 | * If an endpoint with this identifier already exists, its user might be changed. |
| 258 | * @param[in] user_name Arbitrary identifier of the user. |
| 259 | * If an user with this identifier already exists, its contents will be changed. |
| 260 | * @param[in] pubkey_name Arbitrary identifier of the user's public key. |
| 261 | * If a public key with this identifier already exists for this user, its contents will be changed. |
| 262 | * @param[in] pubkey_path Path to a file containing the user's public key. |
| 263 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 264 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 265 | * @return 0 on success, non-zero otherwise. |
| 266 | */ |
| 267 | int nc_server_config_new_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name, |
| 268 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
| 269 | |
| 270 | /** |
| 271 | * @brief Deletes an SSH user's public key from the YANG data. |
| 272 | * |
| 273 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 274 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 275 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 276 | * If NULL, all of the users public keys will be deleted. |
| 277 | * @param[in,out] config Configuration YANG data. |
| 278 | * @return 0 on success, non-zero otherwise. |
| 279 | */ |
| 280 | int nc_server_config_new_ssh_del_user_pubkey(const char *endpt_name, const char *user_name, |
| 281 | const char *pubkey_name, struct lyd_node **config); |
| 282 | |
| 283 | /** |
| 284 | * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method. |
| 285 | * |
| 286 | * @param[in] ctx libyang context. |
| 287 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 288 | * If an endpoint with this identifier already exists, its user might be changed. |
| 289 | * @param[in] user_name Arbitrary identifier of the user. |
| 290 | * If an user with this identifier already exists, its contents will be changed. |
| 291 | * @param[in] password Cleartext password to be set for the user. |
| 292 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 293 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 294 | * @return 0 on success, non-zero otherwise. |
| 295 | */ |
| 296 | int nc_server_config_new_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name, |
| 297 | const char *user_name, const char *password, struct lyd_node **config); |
| 298 | |
| 299 | /** |
| 300 | * @brief Deletes an SSH user's password from the YANG data. |
| 301 | * |
| 302 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 303 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 304 | * @param[in,out] config Configuration YANG data. |
| 305 | * @return 0 on success, non-zero otherwise. |
| 306 | */ |
| 307 | int nc_server_config_new_ssh_del_user_password(const char *endpt_name, const char *user_name, |
| 308 | struct lyd_node **config); |
| 309 | |
| 310 | /** |
| 311 | * @brief Creates new YANG configuration data nodes for an SSH user's none authentication method. |
| 312 | * |
| 313 | * @param[in] ctx libyang context. |
| 314 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 315 | * If an endpoint with this identifier already exists, its user might be changed. |
| 316 | * @param[in] user_name Arbitrary identifier of the user. |
| 317 | * If an user with this identifier already exists, its contents will be changed. |
| 318 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 319 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 320 | * @return 0 on success, non-zero otherwise. |
| 321 | */ |
| 322 | int nc_server_config_new_ssh_user_none(const struct ly_ctx *ctx, const char *endpt_name, |
| 323 | const char *user_name, struct lyd_node **config); |
| 324 | |
| 325 | /** |
| 326 | * @brief Deletes an SSH user's none authentication method from the YANG data. |
| 327 | * |
| 328 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 329 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 330 | * @param[in,out] config Configuration YANG data. |
| 331 | * @return 0 on success, non-zero otherwise. |
| 332 | */ |
| 333 | int nc_server_config_new_ssh_del_user_none(const char *endpt_name, const char *user_name, |
| 334 | struct lyd_node **config); |
| 335 | |
| 336 | /** |
| 337 | * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method. |
| 338 | * |
| 339 | * @param[in] ctx libyang context. |
| 340 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 341 | * If an endpoint with this identifier already exists, its user might be changed. |
| 342 | * @param[in] user_name Arbitrary identifier of the user. |
| 343 | * If an user with this identifier already exists, its contents will be changed. |
| 344 | * @param[in] pam_config_name Name of the PAM configuration file. |
| 345 | * @param[in] pam_config_name Optional. The absolute path to the directory in which the configuration file |
| 346 | * with the name conf_name is located. A newer version (>= 1.4) of PAM library is required to be able to specify |
| 347 | * the path. If NULL is passed, then the PAM's system directories will be searched (usually /etc/pam.d/). |
| 348 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 349 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 350 | * @return 0 on success, non-zero otherwise. |
| 351 | */ |
| 352 | int nc_server_config_new_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name, |
| 353 | const char *user_name, const char *pam_config_name, const char *pam_config_dir, struct lyd_node **config); |
| 354 | |
| 355 | /** |
| 356 | * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data. |
| 357 | * |
| 358 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 359 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 360 | * @param[in,out] config Configuration YANG data. |
| 361 | * @return 0 on success, non-zero otherwise. |
| 362 | */ |
| 363 | int nc_server_config_new_ssh_del_user_interactive(const char *endpt_name, const char *user_name, |
| 364 | struct lyd_node **config); |
| 365 | |
| 366 | /** |
| 367 | * @brief Deletes an SSH user from the YANG data. |
| 368 | * |
| 369 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 370 | * @param[in] user_name Optional identifier of an user to be deleted. |
| 371 | * If NULL, all of the users on this endpoint will be deleted. |
| 372 | * @param[in,out] config Configuration YANG data. |
| 373 | * @return 0 on success, non-zero otherwise. |
| 374 | */ |
| 375 | int nc_server_config_new_ssh_del_user(const char *endpt_name, |
| 376 | const char *user_name, struct lyd_node **config); |
| 377 | |
| 378 | /** |
| 379 | * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore. |
| 380 | * |
| 381 | * The public key's located in the bag will be used for client authentication. |
| 382 | * |
| 383 | * @param[in] ctx libyang context. |
| 384 | * @param[in] endpt_name Arbitrary identifier of an endpoint. |
| 385 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 386 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 387 | * If an endpoint's user with this identifier already exists, its contents will be changed. |
| 388 | * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication. |
| 389 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 390 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 391 | * @return 0 on success, non-zero otherwise. |
| 392 | */ |
| 393 | int nc_server_config_new_ssh_truststore_reference(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name, |
| 394 | const char *truststore_reference, struct lyd_node **config); |
| 395 | |
| 396 | /** |
| 397 | * @brief Deletes a truststore reference from the YANG data. |
| 398 | * |
| 399 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 400 | * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted. |
| 401 | * @param[in,out] config Configuration YANG data. |
| 402 | * @return 0 on success, non-zero otherwise. |
| 403 | */ |
| 404 | int nc_server_config_new_ssh_del_truststore_reference(const char *endpt_name, const char *user_name, |
| 405 | struct lyd_node **config); |
| 406 | |
| 407 | /** |
| 408 | * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users. |
| 409 | * |
| 410 | * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is |
| 411 | * found, the referenced endpoint's configured users will be tried. |
| 412 | * |
| 413 | * @param[in] ctx libyang context |
| 414 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 415 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 416 | * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data |
| 417 | * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle. |
| 418 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 419 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 420 | * @return 0 on success, non-zero otherwise. |
| 421 | */ |
| 422 | int nc_config_new_ssh_endpoint_user_reference(const struct ly_ctx *ctx, const char *endpt_name, |
| 423 | const char *referenced_endpt, struct lyd_node **config); |
| 424 | |
| 425 | /** |
| 426 | * @brief Deletes reference to another SSH endpoint's users from the YANG data. |
| 427 | * |
| 428 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 429 | * @param[in,out] config Configuration YANG data. |
| 430 | * @return 0 on success, non-zero otherwise. |
| 431 | */ |
| 432 | int nc_config_new_ssh_del_endpoint_user_reference(const char *endpt_name, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 433 | |
| 434 | /** |
| 435 | * @brief Creates new YANG configuration data nodes for host-key algorithms replacing any previous ones. |
| 436 | * |
| 437 | * Supported algorithms are: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, |
| 438 | * rsa-sha2-512, rsa-sha2-256, ssh-rsa and ssh-dss. |
| 439 | * |
| 440 | * @param[in] ctx libyang context |
| 441 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 442 | * If an endpoint with this identifier already exists, its host-key algorithms will be replaced. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 443 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 444 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 445 | * @param[in] alg_count Number of following algorithms. |
| 446 | * @param[in] ... String literals of host-key algorithms in a decreasing order of preference. |
| 447 | * @return 0 on success, non-zero otherwise. |
| 448 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 449 | int nc_server_config_new_ssh_host_key_algs(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 450 | struct lyd_node **config, int alg_count, ...); |
| 451 | |
| 452 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 453 | * @brief Deletes a hostkey algorithm from the YANG data. |
| 454 | * |
| 455 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 456 | * @param[in] alg Optional algorithm to be deleted. |
| 457 | * If NULL, all of the hostkey algorithms on this endpoint will be deleted. |
| 458 | * @param[in,out] config Configuraiton YANG data. |
| 459 | * @return 0 on success, non-zero otherwise. |
| 460 | */ |
| 461 | int nc_server_config_new_ssh_del_host_key_alg(const char *endpt_name, const char *alg, struct lyd_node **config); |
| 462 | |
| 463 | /** |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 464 | * @brief Creates new YANG configuration data nodes for key exchange algorithms replacing any previous ones. |
| 465 | * |
| 466 | * Supported algorithms are: diffie-hellman-group-exchange-sha1, curve25519-sha256, ecdh-sha2-nistp256, |
| 467 | * ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group18-sha512, diffie-hellman-group16-sha512, |
| 468 | * diffie-hellman-group-exchange-sha256 and diffie-hellman-group14-sha256. |
| 469 | * |
| 470 | * @param[in] ctx libyang context |
| 471 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 472 | * If an endpoint with this identifier already exists, its key exchange algorithms will be replaced. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 473 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 474 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 475 | * @param[in] alg_count Number of following algorithms. |
| 476 | * @param[in] ... String literals of key exchange algorithms in a decreasing order of preference. |
| 477 | * @return 0 on success, non-zero otherwise. |
| 478 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 479 | int nc_server_config_new_ssh_key_exchange_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 480 | int alg_count, ...); |
| 481 | |
| 482 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 483 | * @brief Deletes a key exchange algorithm from the YANG data. |
| 484 | * |
| 485 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 486 | * @param[in] alg Optional algorithm to be deleted. |
| 487 | * If NULL, all of the key exchange algorithms on this endpoint will be deleted. |
| 488 | * @param[in,out] config Configuraiton YANG data. |
| 489 | * @return 0 on success, non-zero otherwise. |
| 490 | */ |
| 491 | int nc_server_config_new_ssh_del_key_exchange_alg(const char *endpt_name, const char *alg, struct lyd_node **config); |
| 492 | |
| 493 | /** |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 494 | * @brief Creates new YANG configuration data nodes for encryption algorithms replacing any previous ones. |
| 495 | * |
| 496 | * Supported algorithms are: aes256-ctr, aes192-ctr, aes128-ctr, aes256-cbc, aes192-cbc, aes128-cbc, blowfish-cbc |
| 497 | * triple-des-cbc and none. |
| 498 | * |
| 499 | * @param[in] ctx libyang context |
| 500 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 501 | * If an endpoint with this identifier already exists, its encryption algorithms will be replaced. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 502 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 503 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 504 | * @param[in] alg_count Number of following algorithms. |
| 505 | * @param[in] ... String literals of encryption algorithms in a decreasing order of preference. |
| 506 | * @return 0 on success, non-zero otherwise. |
| 507 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 508 | int nc_server_config_new_ssh_encryption_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 509 | int alg_count, ...); |
| 510 | |
| 511 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 512 | * @brief Deletes an encryption algorithm from the YANG data. |
| 513 | * |
| 514 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 515 | * @param[in] alg Optional algorithm to be deleted. |
| 516 | * If NULL, all of the encryption algorithms on this endpoint will be deleted. |
| 517 | * @param[in,out] config Configuraiton YANG data. |
| 518 | * @return 0 on success, non-zero otherwise. |
| 519 | */ |
| 520 | int nc_server_config_new_ssh_del_encryption_alg(const char *endpt_name, const char *alg, struct lyd_node **config); |
| 521 | |
| 522 | /** |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 523 | * @brief Creates new YANG configuration data nodes for mac algorithms replacing any previous ones. |
| 524 | * |
| 525 | * Supported algorithms are: hmac-sha2-256, hmac-sha2-512 and hmac-sha1. |
| 526 | * |
| 527 | * @param[in] ctx libyang context |
| 528 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 529 | * If an endpoint with this identifier already exists, its mac algorithms will be replaced. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 530 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 531 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 532 | * @param[in] alg_count Number of following algorithms. |
| 533 | * @param[in] ... String literals of mac algorithms in a decreasing order of preference. |
| 534 | * @return 0 on success, non-zero otherwise. |
| 535 | */ |
roman | 466719d | 2023-05-05 16:14:37 +0200 | [diff] [blame] | 536 | int nc_server_config_new_ssh_mac_algs(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 537 | int alg_count, ...); |
| 538 | |
| 539 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 540 | * @brief Deletes a mac algorithm from the YANG data. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 541 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 542 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 543 | * @param[in] alg Optional algorithm to be deleted. |
| 544 | * If NULL, all of the mac algorithms on this endpoint will be deleted. |
| 545 | * @param[in,out] config Configuraiton YANG data. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 546 | * @return 0 on success, non-zero otherwise. |
| 547 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 548 | int nc_server_config_new_ssh_del_mac_alg(const char *endpt_name, const char *alg, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 549 | |
| 550 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 551 | * @} |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 552 | */ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 553 | |
| 554 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 555 | * @defgroup server_config_tls TLS Server Configuration |
| 556 | * @ingroup server_config |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 557 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 558 | * @brief TLS server configuration creation and deletion |
| 559 | * @{ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 560 | */ |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 561 | |
| 562 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 563 | * @brief Creates new YANG configuration data nodes for a server's certificate. |
| 564 | * |
| 565 | * @param[in] ctx libyang context. |
| 566 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 567 | * If an endpoint with this identifier already exists, its server certificate will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 568 | * @param[in] pubkey_path Optional path to the server's public key file. If not provided, |
| 569 | * it will be generated from the private key. |
| 570 | * @param[in] privkey_path Path to the server's private key file. |
| 571 | * @param[in] certificate_path Path to the server's certificate file. |
| 572 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 573 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 574 | * @return 0 on success, non-zero otherwise. |
| 575 | */ |
| 576 | int nc_server_config_new_tls_server_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *pubkey_path, |
| 577 | const char *privkey_path, const char *certificate_path, struct lyd_node **config); |
| 578 | |
| 579 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 580 | * @brief Deletes the server's certificate from the YANG data. |
| 581 | * |
| 582 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 583 | * @param[in,out] config Configuration YANG data. |
| 584 | * @return 0 on success, non-zero otherwise. |
| 585 | */ |
| 586 | int nc_server_config_new_tls_del_server_certificate(const char *endpt_name, struct lyd_node **config); |
| 587 | |
| 588 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 589 | * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate. |
| 590 | * |
| 591 | * @param[in] ctx libyang context. |
| 592 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 593 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 594 | * @param[in] cert_name Arbitrary identifier of the client's certificate. |
| 595 | * If a client certificate with this indetifier already exists, it will be changed. |
| 596 | * @param[in] cert_path Path to the client's certificate file. |
| 597 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 598 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 599 | * @return 0 on success, non-zero otherwise. |
| 600 | */ |
| 601 | int nc_server_config_new_tls_client_certificate(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
| 602 | const char *cert_path, struct lyd_node **config); |
| 603 | |
| 604 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 605 | * @brief Deletes a client (end-entity) certificate from the YANG data. |
| 606 | * |
| 607 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 608 | * @param[in] cert_name Optional name of a certificate to be deleted. |
| 609 | * If NULL, all of the end-entity certificates on the given endpoint will be deleted. |
| 610 | * @param[in,out] config Configuration YANG data. |
| 611 | * @return 0 on success, non-zero otherwise. |
| 612 | */ |
| 613 | int nc_server_config_new_tls_del_client_certificate(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
| 614 | |
| 615 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 616 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 617 | * |
| 618 | * @param[in] ctx libyang context. |
| 619 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 620 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 621 | * @param[in] cert_name Arbitrary identifier of the certificate authority certificate. |
| 622 | * If a CA with this indetifier already exists, it will be changed. |
| 623 | * @param[in] cert_path Path to the CA certificate file. |
| 624 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 625 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 626 | * @return 0 on success, non-zero otherwise. |
| 627 | */ |
| 628 | int nc_server_config_new_tls_client_ca(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
| 629 | const char *cert_path, struct lyd_node **config); |
| 630 | |
| 631 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 632 | * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data. |
| 633 | * |
| 634 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 635 | * @param[in] cert_name Optional name of a certificate to be deleted. |
| 636 | * If NULL, all of the CA certificates on the given endpoint will be deleted. |
| 637 | * @param[in,out] config Configuration YANG data. |
| 638 | * @return 0 on success, non-zero otherwise. |
| 639 | */ |
| 640 | int nc_server_config_new_tls_del_client_ca(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
| 641 | |
| 642 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 643 | * @brief Creates new YANG configuration data nodes for a cert-to-name entry. |
| 644 | * |
| 645 | * @param[in] ctx libyang context. |
| 646 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 647 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 648 | * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier). |
| 649 | * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is |
| 650 | * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry. |
| 651 | * @param[in] map_type Mapping username to the certificate option. |
| 652 | * @param[in] name Username for this cert-to-name entry. |
| 653 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 654 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 655 | * @return 0 on success, non-zero otherwise. |
| 656 | */ |
| 657 | int nc_server_config_new_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint, |
| 658 | NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 659 | |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 660 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 661 | * @brief Deletes a cert-to-name entry from the YANG data. |
| 662 | * |
| 663 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 664 | * @param[in] id Optional ID of the CTN entry. |
| 665 | * If 0, all of the cert-to-name entries on the given endpoint will be deleted. |
| 666 | * @param[in,out] config Configuration YANG data. |
| 667 | * @return 0 on success, non-zero otherwise. |
| 668 | */ |
| 669 | int nc_server_config_new_tls_del_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config); |
| 670 | |
| 671 | /** |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 672 | * @brief Creates new YANG configuration data nodes for a TLS version. |
| 673 | * |
| 674 | * @param[in] ctx libyang context. |
| 675 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 676 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 677 | * @param[in] tls_version TLS version to be used. Call this multiple times to set |
| 678 | * the accepted versions of the TLS protocol and let the client and server negotiate |
| 679 | * the given version. |
| 680 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 681 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 682 | * @return 0 on success, non-zero otherwise. |
| 683 | */ |
| 684 | int nc_server_config_new_tls_version(const struct ly_ctx *ctx, const char *endpt_name, |
| 685 | NC_TLS_VERSION tls_version, struct lyd_node **config); |
| 686 | |
| 687 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 688 | * @brief Deletes a TLS version from the YANG data. |
| 689 | * |
| 690 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 691 | * @param[in] tls_version TLS version to be deleted. |
| 692 | * @param[in,out] config Configuration YANG data. |
| 693 | * @return 0 on success, non-zero otherwise. |
| 694 | */ |
| 695 | int nc_server_config_new_tls_del_version(const char *endpt_name, NC_TLS_VERSION tls_version, struct lyd_node **config); |
| 696 | |
| 697 | /** |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 698 | * @brief Creates new YANG configuration data nodes for a TLS cipher. |
| 699 | * |
| 700 | * @param[in] ctx libyang context. |
| 701 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 702 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 703 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 704 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 705 | * @param[in] cipher_count Number of ciphers. |
| 706 | * @param[in] ... TLS ciphers. These ciphers MUST be in the format as listed in the |
| 707 | * iana-tls-cipher-suite-algs YANG model (lowercase and separated by dashes). Regardless |
| 708 | * of the TLS protocol version used, all of these ciphers will be tried and some of them |
| 709 | * might not be set (TLS handshake might fail then). For the list of supported ciphers see |
| 710 | * the OpenSSL documentation. |
| 711 | * @return 0 on success, non-zero otherwise. |
| 712 | */ |
| 713 | int nc_server_config_new_tls_ciphers(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config, |
roman | 08f67f4 | 2023-06-08 13:51:54 +0200 | [diff] [blame] | 714 | int cipher_count, ...); |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 715 | |
roman | faecc58 | 2023-06-15 16:13:31 +0200 | [diff] [blame] | 716 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 717 | * @brief Deletes a TLS cipher from the YANG data. |
| 718 | * |
| 719 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 720 | * @param[in] cipher TLS cipher to be deleted. |
| 721 | * @param[in,out] config Configuration YANG data. |
| 722 | * @return 0 on success, non-zero otherwise. |
| 723 | */ |
| 724 | int nc_server_config_new_tls_del_cipher(const char *endpt_name, const char *cipher, struct lyd_node **config); |
| 725 | |
| 726 | /** |
roman | faecc58 | 2023-06-15 16:13:31 +0200 | [diff] [blame] | 727 | * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via a local file. |
| 728 | * |
| 729 | * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling |
| 730 | * this function will remove any CRL YANG nodes created by the other two functions. |
| 731 | * |
| 732 | * @param[in] ctx libyang context. |
| 733 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 734 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | faecc58 | 2023-06-15 16:13:31 +0200 | [diff] [blame] | 735 | * @param[in] path Path to a DER/PEM encoded CRL file. |
| 736 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 737 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 738 | * @return 0 on success, non-zero otherwise. |
| 739 | */ |
| 740 | int nc_server_config_new_tls_crl_path(const struct ly_ctx *ctx, const char *endpt_name, const char *path, struct lyd_node **config); |
| 741 | |
| 742 | /** |
| 743 | * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via an URL. |
| 744 | * |
| 745 | * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling |
| 746 | * this function will remove any CRL YANG nodes created by the other two functions. |
| 747 | * |
| 748 | * @param[in] ctx libyang context. |
| 749 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 750 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | faecc58 | 2023-06-15 16:13:31 +0200 | [diff] [blame] | 751 | * @param[in] url URL from which the CRL file will be downloaded. The file has to be in the DER or PEM format. |
| 752 | * The allowed protocols are all the protocols supported by CURL. |
| 753 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 754 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 755 | * @return 0 on success, non-zero otherwise. |
| 756 | */ |
| 757 | int nc_server_config_new_tls_crl_url(const struct ly_ctx *ctx, const char *endpt_name, const char *url, struct lyd_node **config); |
| 758 | |
| 759 | /** |
| 760 | * @brief Creates new YANG configuration data nodes for a Certificate Revocation List via certificate extensions. |
| 761 | * |
| 762 | * The chain of configured Certificate Authorities will be examined. For each certificate in this chain all the |
| 763 | * CRLs from the URLs specified in their extension fields CRL Distribution Points will be downloaded and used. |
| 764 | * Beware that you can choose up to one function between the three CRL alternatives on a given endpoint and calling |
| 765 | * this function will remove any CRL YANG nodes created by the other two functions. |
| 766 | * |
| 767 | * @param[in] ctx libyang context. |
| 768 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 769 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | faecc58 | 2023-06-15 16:13:31 +0200 | [diff] [blame] | 770 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 771 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 772 | * @return 0 on success, non-zero otherwise. |
| 773 | */ |
| 774 | int nc_server_config_new_tls_crl_cert_ext(const struct ly_ctx *ctx, const char *endpt_name, struct lyd_node **config); |
| 775 | |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 776 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 777 | * @brief Deletes all the CRL nodes from the YANG data. |
| 778 | * |
| 779 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 780 | * @param[in,out] config Configuration YANG data. |
| 781 | * @return 0 on success, non-zero otherwise. |
| 782 | */ |
| 783 | int nc_server_config_new_tls_del_crl(const char *endpt_name, struct lyd_node **config); |
| 784 | |
| 785 | /** |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 786 | * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates. |
| 787 | * |
| 788 | * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is |
| 789 | * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries. |
| 790 | * |
| 791 | * @param[in] ctx libyang context |
| 792 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 793 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 794 | * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data |
| 795 | * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle. |
| 796 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 797 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 798 | * @return 0 on success, non-zero otherwise. |
| 799 | */ |
| 800 | int nc_config_new_tls_endpoint_client_reference(const struct ly_ctx *ctx, const char *endpt_name, |
| 801 | const char *referenced_endpt, struct lyd_node **config); |
| 802 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 803 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 804 | * @brief Deletes reference to another TLS endpoint's users from the YANG data. |
| 805 | * |
| 806 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 807 | * @param[in,out] config Configuration YANG data. |
| 808 | * @return 0 on success, non-zero otherwise. |
| 809 | */ |
| 810 | int nc_config_new_tls_del_endpoint_client_reference(const char *endpt_name, struct lyd_node **config); |
| 811 | |
| 812 | /** |
| 813 | * @} |
| 814 | */ |
| 815 | |
| 816 | /** |
| 817 | * @defgroup server_config_ch Call-Home server Configuration |
| 818 | * @ingroup server_config |
| 819 | * |
| 820 | * @brief Call-Home server configuration creation and deletion |
| 821 | * @{ |
| 822 | */ |
| 823 | |
| 824 | /** |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 825 | * @brief Creates new YANG configuration data nodes for a call-home client's address and port. |
| 826 | * |
| 827 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 828 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 829 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 830 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 831 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 832 | * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS. |
| 833 | * @param[in] address Address to connect to. |
| 834 | * @param[in] port Port to connect to. |
| 835 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 836 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 837 | * @return 0 on success, non-zero otherwise. |
| 838 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 839 | int nc_server_config_new_ch_address_port(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 840 | NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config); |
| 841 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 842 | #endif /* NC_ENABLED_SSH_TLS */ |
| 843 | |
| 844 | /** |
| 845 | * @brief Deletes a Call-Home client from the YANG data. |
| 846 | * |
| 847 | * @param[in] client_name Optional identifier of a client to be deleted. |
| 848 | * If NULL, all of the Call-Home clients will be deleted. |
| 849 | * @param[in,out] config Configuration YANG data. |
| 850 | * @return 0 on success, non-zero otherwise. |
| 851 | */ |
| 852 | int nc_server_config_new_del_ch_client(const char *client_name, struct lyd_node **config); |
| 853 | |
| 854 | /** |
| 855 | * @brief Deletes a Call-Home endpoint from the YANG data. |
| 856 | * |
| 857 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 858 | * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted. |
| 859 | * If NULL, all of the CH endpoints which belong to the given client will be deleted. |
| 860 | * @param[in,out] config Configuration YANG data. |
| 861 | * @return 0 on success, non-zero otherwise. |
| 862 | */ |
| 863 | int nc_server_config_new_ch_del_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config); |
| 864 | |
| 865 | /** |
| 866 | * @brief Creates new YANG configuration data nodes for the call-home persistent connection type. |
| 867 | * |
| 868 | * This is the default connection type. If periodic connection type was set before, it will be unset. |
| 869 | * |
| 870 | * @param[in] ctx libyang context. |
| 871 | * @param[in] client_name Arbitrary identifier of the call-home client. |
| 872 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 873 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 874 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 875 | * @return 0 on success, non-zero otherwise. |
| 876 | */ |
| 877 | int nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config); |
| 878 | |
| 879 | /** |
| 880 | * @brief Creates new YANG configuration data nodes for the period parameter of the call-home periodic connection type. |
| 881 | * |
| 882 | * If called, the persistent connection type will be replaced by periodic. |
| 883 | * |
| 884 | * @param[in] ctx libyang context. |
| 885 | * @param[in] client_name Arbitrary identifier of the call-home client. |
| 886 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 887 | * @param[in] period Duration between periodic connections in minutes. |
| 888 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 889 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 890 | * @return 0 on success, non-zero otherwise. |
| 891 | */ |
| 892 | int nc_server_config_new_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period, |
| 893 | struct lyd_node **config); |
| 894 | |
| 895 | /** |
| 896 | * @brief Deletes the Call-Home period parameter of the periodic connection type from the YANG data. |
| 897 | * |
| 898 | * This behaves the same as setting the period to 60 minutes, which is the default value of this node. |
| 899 | * |
| 900 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 901 | * @param[in,out] config Configuration YANG data. |
| 902 | * @return 0 on success, non-zero otherwise. |
| 903 | */ |
| 904 | int nc_server_config_new_ch_del_period(const char *client_name, struct lyd_node **config); |
| 905 | |
| 906 | /** |
| 907 | * @brief Creates new YANG configuration data nodes for the anchor time parameter of the call-home periodic connection type. |
| 908 | * |
| 909 | * If called, the persistent connection type will be replaced by periodic. |
| 910 | * |
| 911 | * @param[in] ctx libyang context. |
| 912 | * @param[in] client_name Arbitrary identifier of the call-home client. |
| 913 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 914 | * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined. |
| 915 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 916 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 917 | * @return 0 on success, non-zero otherwise. |
| 918 | */ |
| 919 | int nc_server_config_new_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name, |
| 920 | const char *anchor_time, struct lyd_node **config); |
| 921 | |
| 922 | /** |
| 923 | * @brief Deletes the Call-Home anchor time parameter of the periodic connection type from the YANG data. |
| 924 | * |
| 925 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 926 | * @param[in,out] config Configuration YANG data. |
| 927 | * @return 0 on success, non-zero otherwise. |
| 928 | */ |
| 929 | int nc_server_config_new_ch_del_anchor_time(const char *client_name, struct lyd_node **config); |
| 930 | |
| 931 | /** |
| 932 | * @brief Creates new YANG configuration data nodes for the idle timeout parameter of the call-home periodic connection type. |
| 933 | * |
| 934 | * If called, the persistent connection type will be replaced by periodic. |
| 935 | * |
| 936 | * @param[in] ctx libyang context. |
| 937 | * @param[in] client_name Arbitrary identifier of the call-home client. |
| 938 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 939 | * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle. |
| 940 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 941 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 942 | * @return 0 on success, non-zero otherwise. |
| 943 | */ |
| 944 | int nc_server_config_new_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name, |
| 945 | uint16_t idle_timeout, struct lyd_node **config); |
| 946 | |
| 947 | /** |
| 948 | * @brief Deletes the Call-Home idle timeout parameter of the periodic connection type from the YANG data. |
| 949 | * |
| 950 | * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node. |
| 951 | * |
| 952 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 953 | * @param[in,out] config Configuration YANG data. |
| 954 | * @return 0 on success, non-zero otherwise. |
| 955 | */ |
| 956 | int nc_server_config_new_ch_del_idle_timeout(const char *client_name, struct lyd_node **config); |
| 957 | |
| 958 | /** |
| 959 | * @brief Creates new YANG configuration data nodes for the call-home reconnect strategy. |
| 960 | * |
| 961 | * @param[in] ctx libyang context. |
| 962 | * @param[in] client_name Arbitrary identifier of the call-home client. |
| 963 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 964 | * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED. |
| 965 | * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5. |
| 966 | * @param[in] max_attempts The number of unsuccessful connection attempts before moving to the next endpoint. Default value is 3. |
| 967 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 968 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 969 | * @return 0 on success, non-zero otherwise. |
| 970 | */ |
| 971 | int nc_server_config_new_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name, |
| 972 | NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config); |
| 973 | |
| 974 | /** |
| 975 | * @brief Resets the values of the Call-Home reconnect strategy nodes to their defaults. |
| 976 | * |
| 977 | * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3. |
| 978 | * |
| 979 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 980 | * @param[in,out] config Configuration YANG data. |
| 981 | * @return 0 on success, non-zero otherwise. |
| 982 | */ |
| 983 | int nc_server_config_new_ch_del_reconnect_strategy(const char *client_name, struct lyd_node **config); |
| 984 | |
| 985 | /** |
| 986 | * @} |
| 987 | */ |
| 988 | |
| 989 | #ifdef NC_ENABLED_SSH_TLS |
| 990 | |
| 991 | /** |
| 992 | * @defgroup server_config_ch_ssh SSH Call-Home Server Configuration |
| 993 | * @ingroup server_config_ch |
| 994 | * |
| 995 | * @brief SSH Call-Home server configuration creation and deletion |
| 996 | * @{ |
| 997 | */ |
| 998 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 999 | /** |
| 1000 | * @brief Creates new YANG data nodes for a call-home SSH hostkey. |
| 1001 | * |
| 1002 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1003 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1004 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1005 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1006 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1007 | * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey. |
| 1008 | * If the endpoint's hostkey with this identifier already exists, its contents will be changed. |
| 1009 | * @param[in] privkey_path Path to a file containing a private key. |
| 1010 | * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported. |
| 1011 | * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be |
| 1012 | * generated from the private key. |
| 1013 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1014 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1015 | * @return 0 on success, non-zero otherwise. |
| 1016 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1017 | int nc_server_config_new_ch_ssh_hostkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 1018 | const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
| 1019 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1020 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1021 | * @brief Deletes a Call-home hostkey from the YANG data. |
| 1022 | * |
| 1023 | * @param[in] client_name Identifier of an existing Call-home client. |
| 1024 | * @param[in] endpt_name Identifier of an existing endpoint which belongs to the given CH client. |
| 1025 | * @param[in] hostkey_name Optional identifier of a hostkey to be deleted. |
| 1026 | * If NULL, all of the hostkeys on the given endpoint will be deleted. |
| 1027 | * @param[in,out] config Configuration YANG data. |
| 1028 | * @return 0 on success, non-zero otherwise. |
| 1029 | */ |
| 1030 | int nc_server_config_new_ch_ssh_del_hostkey(const char *client_name, const char *endpt_name, |
| 1031 | const char *hostkey_name, struct lyd_node **config); |
| 1032 | |
| 1033 | /** |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1034 | * @brief Creates new YANG data nodes for a call-home client's public key. |
| 1035 | * |
| 1036 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1037 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1038 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1039 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1040 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1041 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1042 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
| 1043 | * @param[in] pubkey_name Arbitrary identifier of the user's public key. |
| 1044 | * If the user's public key with this identifier already exists, its contents will be changed. |
| 1045 | * @param[in] pubkey_path Path to a file containing a public key. |
| 1046 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1047 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1048 | * @return 0 on success, non-zero otherwise. |
| 1049 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1050 | int nc_server_config_new_ch_ssh_user_pubkey(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 1051 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
| 1052 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1053 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1054 | * @brief Deletes a Call-home SSH user's public key from the YANG data. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1055 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1056 | * @param[in] client_name Identifier of an existing Call-home client. |
| 1057 | * @param[in] endpt_name Identifier of an existing endpoint which belongs to the given CH client. |
| 1058 | * @param[in] user_name Identifier of an existing SSH user which belongs to the given CH endpoint. |
| 1059 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 1060 | * If NULL, all of the public keys which belong to the given SSH user will be deleted. |
| 1061 | * @param[in,out] config Configuration YANG data. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1062 | * @return 0 on success, non-zero otherwise. |
| 1063 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1064 | int nc_server_config_new_ch_ssh_del_user_pubkey(const char *client_name, const char *endpt_name, |
| 1065 | const char *user_name, const char *pubkey_name, struct lyd_node **config); |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 1066 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1067 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1068 | * @} |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1069 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1070 | |
| 1071 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1072 | * @defgroup server_config_ch_tls TLS Call-Home Server Configuration |
| 1073 | * @ingroup server_config_ch |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1074 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1075 | * @brief TLS Call-Home server configuration creation and deletion |
| 1076 | * @{ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1077 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1078 | |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1079 | /** |
| 1080 | * @brief Creates new YANG configuration data nodes for a call-home server's certificate. |
| 1081 | * |
| 1082 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1083 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1084 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1085 | * @param[in] endpt_name Arbitrary identifier of the call-home client's endpoint. |
| 1086 | * If a call-home client's endpoint with this identifier already exists, its contents will be changed. |
| 1087 | * @param[in] pubkey_path Optional path to the server's public key file. If not provided, |
| 1088 | * it will be generated from the private key. |
| 1089 | * @param[in] privkey_path Path to the server's private key file. |
| 1090 | * @param[in] certificate_path Path to the server's certificate file. |
| 1091 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1092 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1093 | * @return 0 on success, non-zero otherwise. |
| 1094 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1095 | int nc_server_config_new_ch_tls_server_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1096 | const char *pubkey_path, const char *privkey_path, const char *certificate_path, struct lyd_node **config); |
| 1097 | |
| 1098 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1099 | * @brief Deletes a Call-Home server certificate from the YANG data. |
| 1100 | * |
| 1101 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 1102 | * @param[in] endpt_name Identifier of an existing Call-Home endpoint which belongs to the given client. |
| 1103 | * @param[in,out] config Configuration YANG data. |
| 1104 | * @return 0 on success, non-zero otherwise. |
| 1105 | */ |
| 1106 | int nc_server_config_new_ch_tls_del_server_certificate(const char *client_name, const char *endpt_name, |
| 1107 | struct lyd_node **config); |
| 1108 | |
| 1109 | /** |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1110 | * @brief Creates new YANG configuration data nodes for a call-home client's (end-entity) certificate. |
| 1111 | * |
| 1112 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1113 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1114 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1115 | * @param[in] endpt_name Arbitrary identifier of the call-home client's endpoint. |
| 1116 | * If a call-home client's endpoint with this identifier already exists, its contents will be changed. |
| 1117 | * @param[in] cert_name Arbitrary identifier of the call-home endpoint's end-entity certificate. |
| 1118 | * If an call-home endpoint's end-entity certificate with this identifier already exists, its contents will be changed. |
| 1119 | * @param[in] cert_path Path to the certificate file. |
| 1120 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1121 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1122 | * @return 0 on success, non-zero otherwise. |
| 1123 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1124 | int nc_server_config_new_ch_tls_client_certificate(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1125 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1126 | |
| 1127 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1128 | * @brief Deletes a Call-Home client (end-entity) certificate from the YANG data. |
| 1129 | * |
| 1130 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 1131 | * @param[in] endpt_name Identifier of an existing Call-Home endpoint which belongs to the given client. |
| 1132 | * @param[in] cert_name Optional identifier of a client certificate to be deleted. |
| 1133 | * If NULL, all of the client certificates will be deleted. |
| 1134 | * @param[in,out] config Configuration YANG data. |
| 1135 | * @return 0 on success, non-zero otherwise. |
| 1136 | */ |
| 1137 | int nc_server_config_new_ch_tls_del_client_certificate(const char *client_name, const char *endpt_name, |
| 1138 | const char *cert_name, struct lyd_node **config); |
| 1139 | |
| 1140 | /** |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1141 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 1142 | * |
| 1143 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1144 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1145 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1146 | * @param[in] endpt_name Arbitrary identifier of the call-home client's endpoint. |
| 1147 | * If a call-home client's endpoint with this identifier already exists, its contents will be changed. |
| 1148 | * @param[in] cert_name Arbitrary identifier of the call-home endpoint's certificate authority certificate. |
| 1149 | * If an call-home endpoint's CA certificate with this identifier already exists, its contents will be changed. |
| 1150 | * @param[in] cert_path Path to the certificate file. |
| 1151 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1152 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1153 | * @return 0 on success, non-zero otherwise. |
| 1154 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1155 | int nc_server_config_new_ch_tls_client_ca(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1156 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1157 | |
| 1158 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1159 | * @brief Deletes a Call-Home client certificate authority (trust-anchor) certificate from the YANG data. |
| 1160 | * |
| 1161 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 1162 | * @param[in] endpt_name Identifier of an existing Call-Home endpoint which belongs to the given client. |
| 1163 | * @param[in] cert_name Optional identifier of a CA certificate to be deleted. |
| 1164 | * If NULL, all of the CA certificates will be deleted. |
| 1165 | * @param[in,out] config Configuration YANG data. |
| 1166 | * @return 0 on success, non-zero otherwise. |
| 1167 | */ |
| 1168 | int nc_server_config_new_ch_tls_del_client_ca(const char *client_name, const char *endpt_name, |
| 1169 | const char *cert_name, struct lyd_node **config); |
| 1170 | |
| 1171 | /** |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1172 | * @brief Creates new YANG configuration data nodes for a call-home cert-to-name entry. |
| 1173 | * |
| 1174 | * @param[in] ctx libyang context. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1175 | * @param[in] client_name Arbitrary identifier of the call-home client. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1176 | * If a call-home client with this identifier already exists, its contents will be changed. |
| 1177 | * @param[in] endpt_name Arbitrary identifier of the call-home client's endpoint. |
| 1178 | * If a call-home client's endpoint with this identifier already exists, its contents will be changed. |
| 1179 | * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier). |
| 1180 | * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is |
| 1181 | * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry. |
| 1182 | * @param[in] map_type Mapping username to the certificate option. |
| 1183 | * @param[in] name Username for this cert-to-name entry. |
| 1184 | * @param config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1185 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1186 | * @return 0 on success, non-zero otherwise. |
| 1187 | */ |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1188 | int nc_server_config_new_ch_tls_ctn(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1189 | uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 1190 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame^] | 1191 | /** |
| 1192 | * @brief Deletes a Call-Home cert-to-name entry from the YANG data. |
| 1193 | * |
| 1194 | * @param[in] client_name Identifier of an existing Call-Home client. |
| 1195 | * @param[in] endpt_name Identifier of an existing Call-Home endpoint which belongs to the given client. |
| 1196 | * @param[in] id Optional identifier of the Call-Home CTN entry to be deleted. |
| 1197 | * If 0, all of the CTN entries will be deleted. |
| 1198 | * @param[in,out] config Configuration YANG data. |
| 1199 | * @return 0 on success, non-zero otherwise. |
| 1200 | */ |
| 1201 | int nc_server_config_new_ch_tls_del_ctn(const char *client_name, const char *endpt_name, |
| 1202 | uint32_t id, struct lyd_node **config); |
| 1203 | |
| 1204 | /** |
| 1205 | * @} |
| 1206 | */ |
| 1207 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 1208 | #endif /* NC_ENABLED_SSH_TLS */ |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 1209 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1210 | #ifdef __cplusplus |
| 1211 | } |
| 1212 | #endif |
| 1213 | |
| 1214 | #endif /* NC_SESSION_SERVER_H_ */ |