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 | d348b94 | 2023-10-13 14:32:19 +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 | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 39 | * @} Server Configuration |
| 40 | */ |
| 41 | |
| 42 | /** |
| 43 | * @defgroup server_config_functions Server Configuration Functions |
| 44 | * @ingroup server_config |
| 45 | * |
| 46 | * @brief Server-side configuration functions |
| 47 | * @{ |
| 48 | */ |
| 49 | |
| 50 | /** |
| 51 | * @brief Implements all the required modules and their features in the context. |
| 52 | * Needs to be called before any other configuration functions. |
| 53 | * |
| 54 | * If ctx is : |
| 55 | * - NULL: a new context will be created and if the call is successful you have to free it, |
| 56 | * - non NULL: modules will simply be implemented. |
| 57 | * |
| 58 | * Implemented modules: ietf-netconf-server, ietf-x509-cert-to-name, ietf-crypto-types, |
| 59 | * ietf-tcp-common, ietf-ssh-common, iana-ssh-encryption-algs, iana-ssh-key-exchange-algs, |
| 60 | * iana-ssh-mac-algs, iana-ssh-public-key-algs, ietf-keystore, ietf-ssh-server, ietf-truststore, |
| 61 | * ietf-tls-server and libnetconf2-netconf-server. |
| 62 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 63 | * @param[in, out] ctx Optional context in which the modules will be implemented. Created if *ctx is null. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 64 | * @return 0 on success, 1 on error. |
| 65 | */ |
| 66 | int nc_server_config_load_modules(struct ly_ctx **ctx); |
| 67 | |
| 68 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 69 | * @brief Configure server based on the given diff. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 70 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 71 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 72 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 73 | * @param[in] diff YANG diff belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 74 | * The top level node HAS to have an operation (create, replace, delete or none). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 75 | * @return 0 on success, 1 on error. |
| 76 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 77 | int nc_server_config_setup_diff(const struct lyd_node *diff); |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 78 | |
| 79 | /** |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 80 | * @brief Configure server based on the given data. |
| 81 | * |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 82 | * Behaves as if all the nodes in data had the replace operation. That means that the current configuration will be deleted |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 83 | * and just the given data will be applied. |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 84 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 85 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 86 | * @param[in] data YANG data belonging to either ietf-netconf-server, ietf-keystore or ietf-truststore modules. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 87 | * This data __must be valid__. No node can have an operation attribute. |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 88 | * @return 0 on success, 1 on error. |
| 89 | */ |
roman | f6f37a5 | 2023-05-25 14:27:51 +0200 | [diff] [blame] | 90 | int nc_server_config_setup_data(const struct lyd_node *data); |
roman | f02273a | 2023-05-25 09:44:11 +0200 | [diff] [blame] | 91 | |
| 92 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 93 | * @brief Configure server based on the given data stored in a file. |
| 94 | * |
roman | 0f5fa42 | 2023-08-07 09:03:24 +0200 | [diff] [blame] | 95 | * Wrapper around ::nc_server_config_setup_data() hiding work with parsing the data. |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 96 | * Context must already have implemented the required modules, see ::nc_server_config_load_modules(). |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 97 | * |
| 98 | * @param[in] ctx libyang context. |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 99 | * @param[in] path Path to a file with ietf-netconf-server, ietf-keystore or ietf-truststore YANG data. |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 100 | * This data __must be valid__. No node can have an operation attribute. |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 101 | * @return 0 on success, 1 on error. |
| 102 | */ |
| 103 | int nc_server_config_setup_path(const struct ly_ctx *ctx, const char *path); |
| 104 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 105 | #ifdef NC_ENABLED_SSH_TLS |
| 106 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 107 | /** |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 108 | * @brief Creates new YANG configuration data nodes for address and port. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 109 | * |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 110 | * @param[in] ctx libyang context. |
| 111 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 112 | * If an endpoint with this identifier already exists, its contents might be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 113 | * @param[in] transport Either SSH or TLS transport for the given endpoint. |
| 114 | * @param[in] address New listening address. |
| 115 | * @param[in] port New listening port. |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 116 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 117 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 118 | * @return 0 on success, non-zero otherwise. |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 119 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 120 | int nc_server_config_add_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] | 121 | const char *address, uint16_t port, struct lyd_node **config); |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 122 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 123 | #endif /* NC_ENABLED_SSH_TLS */ |
| 124 | |
| 125 | /** |
| 126 | * @brief Deletes an endpoint from the YANG data. |
| 127 | * |
| 128 | * @param[in] endpt_name Optional identifier of an endpoint to be deleted. |
| 129 | * If NULL, all of the endpoints will be deleted. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 130 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 131 | * @return 0 on success, non-zero otherwise. |
| 132 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 133 | int nc_server_config_del_endpt(const char *endpt_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 134 | |
| 135 | #ifdef NC_ENABLED_SSH_TLS |
| 136 | |
| 137 | /** |
| 138 | * @brief Creates new YANG data nodes for an asymmetric key in the keystore. |
| 139 | * |
| 140 | * @param[in] ctx libyang context. |
roman | 1314591 | 2023-08-17 15:36:54 +0200 | [diff] [blame] | 141 | * @param[in] ti Transport in which the key pair will be used. Either SSH or TLS. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 142 | * @param[in] asym_key_name Identifier of the asymmetric key pair. |
| 143 | * This identifier is used to reference the key pair. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 144 | * @param[in] privkey_path Path to a private key file. |
| 145 | * @param[in] pubkey_path Optional path a public key file. |
| 146 | * If not supplied, it will be generated from the private key. |
| 147 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 148 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 149 | * @return 0 on success, non-zero otherwise. |
| 150 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 151 | int nc_server_config_add_keystore_asym_key(const struct ly_ctx *ctx, NC_TRANSPORT_IMPL ti, const char *asym_key_name, |
roman | 1314591 | 2023-08-17 15:36:54 +0200 | [diff] [blame] | 152 | const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * @brief Deletes a keystore's asymmetric key from the YANG data. |
| 156 | * |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 157 | * @param[in] asym_key_name Optional identifier of the asymmetric key to be deleted. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 158 | * If NULL, all of the asymmetric keys in the keystore will be deleted. |
| 159 | * @param[in,out] config Configuration YANG data tree. |
| 160 | * @return 0 on success, non-zero otherwise. |
| 161 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 162 | int nc_server_config_del_keystore_asym_key(const char *asym_key_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * @brief Creates new YANG data nodes for a certificate in the keystore. |
| 166 | * |
roman | 6430c15 | 2023-10-12 11:28:47 +0200 | [diff] [blame] | 167 | * A certificate can not exist without its asymmetric key, so you must create an asymmetric key |
| 168 | * with the same identifier you pass to this function. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 169 | * |
| 170 | * @param[in] ctx libyang context. |
| 171 | * @param[in] asym_key_name Arbitrary identifier of the asymmetric key. |
| 172 | * If an asymmetric key pair with this name already exists, its contents will be changed. |
| 173 | * @param[in] cert_name Arbitrary identifier of the key pair's certificate. |
| 174 | * If a certificate with this name already exists, its contents will be changed. |
| 175 | * @param[in] cert_path Path to the PEM encoded certificate file. |
| 176 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 177 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 178 | * @return 0 on success, non-zero otherwise. |
| 179 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 180 | int nc_server_config_add_keystore_cert(const struct ly_ctx *ctx, const char *asym_key_name, const char *cert_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 181 | const char *cert_path, struct lyd_node **config); |
| 182 | |
| 183 | /** |
| 184 | * @brief Deletes a keystore's certificate from the YANG data. |
| 185 | * |
| 186 | * @param[in] asym_key_name Identifier of an existing asymmetric key pair. |
| 187 | * @param[in] cert_name Optional identifier of a certificate to be deleted. |
| 188 | * If NULL, all of the certificates belonging to the asymmetric key pair will be deleted. |
| 189 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 190 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 191 | * @return 0 on success, non-zero otherwise. |
| 192 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 193 | int nc_server_config_del_keystore_cert(const char *asym_key_name, const char *cert_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * @brief Creates new YANG data nodes for a public key in the truststore. |
| 197 | * |
| 198 | * @param[in] ctx libyang context. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 199 | * @param[in] pub_bag_name Arbitrary identifier of the public key bag. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 200 | * This name is used to reference the public keys in the bag. |
| 201 | * If a public key bag with this name already exists, its contents will be changed. |
| 202 | * @param[in] pubkey_name Arbitrary identifier of the public key. |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 203 | * If a public key with this name already exists in the given bag, its contents will be changed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 204 | * @param[in] pubkey_path Path to a file containing a public key. |
| 205 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 206 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 207 | * @return 0 on success, non-zero otherwise. |
| 208 | */ |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 209 | int nc_server_config_add_truststore_pubkey(const struct ly_ctx *ctx, const char *pub_bag_name, const char *pubkey_name, |
| 210 | const char *pubkey_path, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * @brief Deletes a truststore's public key from the YANG data. |
| 214 | * |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 215 | * @param[in] pub_bag_name Identifier of an existing public key bag. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 216 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 217 | * If NULL, all of the public keys in the given bag will be deleted. |
| 218 | * @param[in,out] config Configuration YANG data tree. |
| 219 | * @return 0 on success, non-zero otherwise. |
| 220 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 221 | int nc_server_config_del_truststore_pubkey(const char *pub_bag_name, const char *pubkey_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 222 | |
| 223 | /** |
| 224 | * @brief Creates new YANG data nodes for a certificate in the truststore. |
| 225 | * |
| 226 | * @param[in] ctx libyang context. |
| 227 | * @param[in] cert_bag_name Arbitrary identifier of the certificate bag. |
| 228 | * This name is used to reference the certificates in the bag. |
| 229 | * If a certificate bag with this name already exists, its contents will be changed. |
| 230 | * @param[in] cert_name Arbitrary identifier of the certificate. |
| 231 | * If a certificate with this name already exists in the given bag, its contents will be changed. |
| 232 | * @param[in] cert_path Path to a file containing a PEM encoded certificate. |
| 233 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 234 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 235 | * @return 0 on success, non-zero otherwise. |
| 236 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 237 | int nc_server_config_add_truststore_cert(const struct ly_ctx *ctx, const char *cert_bag_name, const char *cert_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 238 | const char *cert_path, struct lyd_node **config); |
| 239 | |
| 240 | /** |
| 241 | * @brief Deletes a truststore's certificate from the YANG data. |
| 242 | * |
| 243 | * @param[in] cert_bag_name Identifier of an existing certificate bag. |
| 244 | * @param[in] cert_name Optional identifier of a certificate to be deleted. |
| 245 | * If NULL, all of the certificates in the given bag will be deleted. |
| 246 | * @param[in,out] config Configuration YANG data tree. |
| 247 | * @return 0 on success, non-zero otherwise. |
| 248 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 249 | int nc_server_config_del_truststore_cert(const char *cert_bag_name, |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 250 | const char *cert_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 251 | |
| 252 | /** |
roman | d05b2ad | 2024-01-23 12:02:40 +0100 | [diff] [blame] | 253 | * @brief Gets the hostkey algorithms supported by the server from the 'iana-ssh-public-key-algs' YANG module. |
| 254 | * |
| 255 | * @param[in] ctx libyang context. |
| 256 | * @param[out] hostkey_algs Container with leaf-lists containing the supported algorithms. |
| 257 | * @return 0 on success, non-zero otherwise. |
| 258 | */ |
| 259 | int nc_server_config_oper_get_hostkey_algs(const struct ly_ctx *ctx, struct lyd_node **hostkey_algs); |
| 260 | |
| 261 | /** |
| 262 | * @brief Gets the key exchange algorithms supported by the server from the 'iana-ssh-key-exchange-algs' YANG module. |
| 263 | * |
| 264 | * @param[in] ctx libyang context. |
| 265 | * @param[out] kex_algs Container with leaf-lists containing the supported algorithms. |
| 266 | * @return 0 on success, non-zero otherwise. |
| 267 | */ |
| 268 | int nc_server_config_oper_get_kex_algs(const struct ly_ctx *ctx, struct lyd_node **kex_algs); |
| 269 | |
| 270 | /** |
| 271 | * @brief Gets the encryption algorithms supported by the server from the 'iana-ssh-encryption-algs' YANG module. |
| 272 | * |
| 273 | * @param[in] ctx libyang context. |
| 274 | * @param[out] encryption_algs Container with leaf-lists containing the supported algorithms. |
| 275 | * @return 0 on success, non-zero otherwise. |
| 276 | */ |
| 277 | int nc_server_config_oper_get_encryption_algs(const struct ly_ctx *ctx, struct lyd_node **encryption_algs); |
| 278 | |
| 279 | /** |
| 280 | * @brief Gets the MAC algorithms supported by the server from the 'iana-ssh-mac-algs' YANG module. |
| 281 | * |
| 282 | * @param[in] ctx libyang context. |
| 283 | * @param[out] mac_algs Container with leaf-lists containing the supported algorithms. |
| 284 | * @return 0 on success, non-zero otherwise. |
| 285 | */ |
| 286 | int nc_server_config_oper_get_mac_algs(const struct ly_ctx *ctx, struct lyd_node **mac_algs); |
| 287 | |
| 288 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 289 | * @} Server Configuration Functions |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 290 | */ |
| 291 | |
| 292 | /** |
| 293 | * @defgroup server_config_ssh SSH Server Configuration |
| 294 | * @ingroup server_config |
| 295 | * |
| 296 | * @brief SSH server configuration creation and deletion |
| 297 | * @{ |
| 298 | */ |
| 299 | |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 300 | /** |
| 301 | * @brief Creates new YANG configuration data nodes for a hostkey. |
| 302 | * |
| 303 | * @param[in] ctx libyang context. |
| 304 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 305 | * If an endpoint with this identifier already exists, its hostkey might be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 306 | * @param[in] hostkey_name Arbitrary identifier of the hostkey. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 307 | * If a hostkey with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 308 | * @param[in] privkey_path Path to a file containing a private key. |
| 309 | * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 310 | * @param[in] pubkey_path Optional path to a file containing a public key. If NULL, public key will be |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 311 | * generated from the private key. |
| 312 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 313 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 314 | * @return 0 on success, non-zero otherwise. |
| 315 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 316 | int nc_server_config_add_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 317 | const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
| 318 | |
| 319 | /** |
| 320 | * @brief Deletes a hostkey from the YANG data. |
| 321 | * |
| 322 | * @param[in] ctx libyang context. |
| 323 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 324 | * @param[in] hostkey_name Optional identifier of the hostkey to be deleted. |
| 325 | * If NULL, all of the hostkeys on this endpoint will be deleted. |
| 326 | * @param[in,out] config Configuration YANG data tree. |
| 327 | * @return 0 on success, non-zero otherwise. |
| 328 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 329 | int nc_server_config_del_ssh_hostkey(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 330 | const char *hostkey_name, struct lyd_node **config); |
| 331 | |
| 332 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 333 | * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore. |
| 334 | * |
| 335 | * This asymmetric key pair will be used as the SSH hostkey. |
| 336 | * |
| 337 | * @param[in] ctx libyang context. |
| 338 | * @param[in] endpt_name Arbitrary identifier of an endpoint. |
| 339 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 340 | * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey. |
| 341 | * If an endpoint's hostkey with this identifier already exists, its contents will be changed. |
| 342 | * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey. |
| 343 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 344 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 345 | * @return 0 on success, non-zero otherwise. |
| 346 | */ |
| 347 | int nc_server_config_add_ssh_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *hostkey_name, |
| 348 | const char *keystore_reference, struct lyd_node **config); |
| 349 | |
| 350 | /** |
| 351 | * @brief Deletes a keystore reference from the YANG data. |
| 352 | * |
| 353 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 354 | * @param[in] hostkey_name Identifier of an existing hostkey on the given endpoint. |
| 355 | * @param[in,out] config Configuration YANG data tree. |
| 356 | * @return 0 on success, non-zero otherwise. |
| 357 | */ |
| 358 | int nc_server_config_del_ssh_keystore_ref(const char *endpt_name, const char *hostkey_name, |
| 359 | struct lyd_node **config); |
| 360 | |
| 361 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 362 | * @brief Creates new YANG configuration data nodes for an SSH user's public key authentication method. |
| 363 | * |
| 364 | * @param[in] ctx libyang context. |
| 365 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 366 | * If an endpoint with this identifier already exists, its user might be changed. |
| 367 | * @param[in] user_name Arbitrary identifier of the user. |
| 368 | * If an user with this identifier already exists, its contents will be changed. |
| 369 | * @param[in] pubkey_name Arbitrary identifier of the user's public key. |
| 370 | * If a public key with this identifier already exists for this user, its contents will be changed. |
| 371 | * @param[in] pubkey_path Path to a file containing the user's public key. |
| 372 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 373 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 374 | * @return 0 on success, non-zero otherwise. |
| 375 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 376 | int nc_server_config_add_ssh_user_pubkey(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 377 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
| 378 | |
| 379 | /** |
| 380 | * @brief Deletes an SSH user's public key from the YANG data. |
| 381 | * |
| 382 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 383 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 384 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 385 | * If NULL, all of the users public keys will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 386 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 387 | * @return 0 on success, non-zero otherwise. |
| 388 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 389 | int nc_server_config_del_ssh_user_pubkey(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 390 | const char *pubkey_name, struct lyd_node **config); |
| 391 | |
| 392 | /** |
roman | a9ec336 | 2023-12-21 10:59:57 +0100 | [diff] [blame] | 393 | * @brief Creates new YANG configuration data nodes for an SSH user that will use system's authorized_keys to authenticate. |
| 394 | * |
| 395 | * The path to the authorized_keys file must be configured to successfully |
| 396 | * authenticate, see ::nc_server_ssh_set_authkey_path_format(). |
| 397 | * |
| 398 | * @param[in] ctx libyang context. |
| 399 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 400 | * If an endpoint with this identifier already exists, its user might be changed. |
| 401 | * @param[in] user_name Arbitrary identifier of the user. |
| 402 | * If an user with this identifier already exists, its contents will be changed. |
| 403 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 404 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 405 | * @return 0 on success, non-zero otherwise. |
| 406 | */ |
| 407 | int nc_server_config_add_ssh_user_authkey(const struct ly_ctx *ctx, const char *endpt_name, |
| 408 | const char *user_name, struct lyd_node **config); |
| 409 | |
| 410 | /** |
| 411 | * @brief Deletes an SSH user's authorized_keys method from the YANG data. |
| 412 | * |
| 413 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 414 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 415 | * @param[in,out] config Modified configuration YANG data tree. |
| 416 | * @return 0 on success, non-zero otherwise. |
| 417 | */ |
| 418 | int nc_server_config_del_ssh_user_authkey(const char *endpt_name, const char *user_name, struct lyd_node **config); |
| 419 | |
| 420 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 421 | * @brief Creates new YANG configuration data nodes for an SSH user's password authentication method. |
| 422 | * |
| 423 | * @param[in] ctx libyang context. |
| 424 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 425 | * If an endpoint with this identifier already exists, its user might be changed. |
| 426 | * @param[in] user_name Arbitrary identifier of the user. |
| 427 | * If an user with this identifier already exists, its contents will be changed. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 428 | * @param[in] password Clear-text password to be set for the user. It will be hashed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 429 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 430 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 431 | * @return 0 on success, non-zero otherwise. |
| 432 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 433 | int nc_server_config_add_ssh_user_password(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 434 | const char *user_name, const char *password, struct lyd_node **config); |
| 435 | |
| 436 | /** |
| 437 | * @brief Deletes an SSH user's password from the YANG data. |
| 438 | * |
| 439 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 440 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 441 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 442 | * @return 0 on success, non-zero otherwise. |
| 443 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 444 | int nc_server_config_del_ssh_user_password(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 445 | struct lyd_node **config); |
| 446 | |
| 447 | /** |
| 448 | * @brief Creates new YANG configuration data nodes for an SSH user's keyboard interactive authentication method. |
| 449 | * |
roman | c651842 | 2023-11-30 16:39:00 +0100 | [diff] [blame] | 450 | * One of Linux PAM, local users, or user callback is used to authenticate users with this SSH method (see \ref ln2doc_kbdint "the documentation"). |
roman | 808f3f6 | 2023-11-23 16:01:04 +0100 | [diff] [blame] | 451 | * |
| 452 | * @param[in] ctx libyang context. |
| 453 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 454 | * If an endpoint with this identifier already exists, its user might be changed. |
| 455 | * @param[in] user_name Arbitrary identifier of the user. |
| 456 | * If an user with this identifier already exists, its contents will be changed. |
| 457 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 458 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 459 | * @return 0 on success, non-zero otherwise. |
| 460 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 461 | int nc_server_config_add_ssh_user_interactive(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 808f3f6 | 2023-11-23 16:01:04 +0100 | [diff] [blame] | 462 | const char *user_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * @brief Deletes an SSH user's keyboard interactive authentication from the YANG data. |
| 466 | * |
| 467 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 468 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 469 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 470 | * @return 0 on success, non-zero otherwise. |
| 471 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 472 | int nc_server_config_del_ssh_user_interactive(const char *endpt_name, const char *user_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 473 | struct lyd_node **config); |
| 474 | |
| 475 | /** |
| 476 | * @brief Deletes an SSH user from the YANG data. |
| 477 | * |
| 478 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 479 | * @param[in] user_name Optional identifier of an user to be deleted. |
| 480 | * If NULL, all of the users on this endpoint will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 481 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 482 | * @return 0 on success, non-zero otherwise. |
| 483 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 484 | int nc_server_config_del_ssh_user(const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 485 | const char *user_name, struct lyd_node **config); |
| 486 | |
| 487 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 488 | * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore. |
| 489 | * |
| 490 | * The public key's located in the bag will be used for client authentication. |
| 491 | * |
| 492 | * @param[in] ctx libyang context. |
| 493 | * @param[in] endpt_name Arbitrary identifier of an endpoint. |
| 494 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 495 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 496 | * If an endpoint's user with this identifier already exists, its contents will be changed. |
| 497 | * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication. |
| 498 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 499 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 500 | * @return 0 on success, non-zero otherwise. |
| 501 | */ |
| 502 | int nc_server_config_add_ssh_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *user_name, |
| 503 | const char *truststore_reference, struct lyd_node **config); |
| 504 | |
| 505 | /** |
| 506 | * @brief Deletes a truststore reference from the YANG data. |
| 507 | * |
| 508 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 509 | * @param[in] user_name Identifier of an user on the given endpoint whose truststore reference will be deleted. |
| 510 | * @param[in,out] config Modified configuration YANG data tree. |
| 511 | * @return 0 on success, non-zero otherwise. |
| 512 | */ |
| 513 | int nc_server_config_del_ssh_truststore_ref(const char *endpt_name, const char *user_name, |
| 514 | struct lyd_node **config); |
| 515 | |
| 516 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 517 | * @brief Creates new YANG configuration data nodes, which will be a reference to another SSH endpoint's users. |
| 518 | * |
| 519 | * Whenever a client tries to connect to the referencing endpoint, all of its users will be tried first. If no match is |
| 520 | * found, the referenced endpoint's configured users will be tried. |
| 521 | * |
| 522 | * @param[in] ctx libyang context |
| 523 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 524 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 525 | * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data |
| 526 | * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle. |
| 527 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 528 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 529 | * @return 0 on success, non-zero otherwise. |
| 530 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 531 | int nc_server_config_add_ssh_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 532 | const char *referenced_endpt, struct lyd_node **config); |
| 533 | |
| 534 | /** |
| 535 | * @brief Deletes reference to another SSH endpoint's users from the YANG data. |
| 536 | * |
| 537 | * @param[in] endpt_name Identifier of an existing endpoint. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 538 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 539 | * @return 0 on success, non-zero otherwise. |
| 540 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 541 | int nc_server_config_del_ssh_endpoint_client_ref(const char *endpt_name, struct lyd_node **config); |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 542 | |
| 543 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 544 | * @} SSH Server Configuration |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 545 | */ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 546 | |
| 547 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 548 | * @defgroup server_config_tls TLS Server Configuration |
| 549 | * @ingroup server_config |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 550 | * |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 551 | * @brief TLS server configuration creation and deletion |
| 552 | * @{ |
roman | 9b1379c | 2023-03-31 10:11:10 +0200 | [diff] [blame] | 553 | */ |
roman | 2e797ef | 2023-06-19 10:47:49 +0200 | [diff] [blame] | 554 | |
| 555 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 556 | * @brief Creates new YANG configuration data nodes for a server's certificate. |
| 557 | * |
| 558 | * @param[in] ctx libyang context. |
| 559 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 560 | * If an endpoint with this identifier already exists, its server certificate will be changed. |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 561 | * @param[in] privkey_path Path to the server's PEM encoded private key file. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 562 | * @param[in] pubkey_path Optional path to the server's public key file. If not provided, |
| 563 | * it will be generated from the private key. |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 564 | * @param[in] cert_path Path to the server's certificate file. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 565 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 566 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 567 | * @return 0 on success, non-zero otherwise. |
| 568 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 569 | int nc_server_config_add_tls_server_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *privkey_path, |
| 570 | const char *pubkey_path, const char *cert_path, struct lyd_node **config); |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 571 | |
| 572 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 573 | * @brief Deletes the server's certificate from the YANG data. |
| 574 | * |
| 575 | * @param[in] endpt_name Identifier of an existing endpoint. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 576 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 577 | * @return 0 on success, non-zero otherwise. |
| 578 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 579 | int nc_server_config_del_tls_server_cert(const char *endpt_name, struct lyd_node **config); |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 580 | |
| 581 | /** |
| 582 | * @brief Creates new YANG configuration data nodes for a keystore reference to the TLS server's certificate. |
| 583 | * |
| 584 | * @param[in] ctx libyang context. |
| 585 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 586 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 587 | * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced. |
| 588 | * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced. |
| 589 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 590 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 591 | * @return 0 on success, non-zero otherwise. |
| 592 | */ |
| 593 | int nc_server_config_add_tls_keystore_ref(const struct ly_ctx *ctx, const char *endpt_name, const char *asym_key_ref, |
| 594 | const char *cert_ref, struct lyd_node **config); |
| 595 | |
| 596 | /** |
| 597 | * @brief Deletes a TLS server certificate keystore reference from the YANG data. |
| 598 | * |
| 599 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 600 | * @param[in,out] config Modified configuration YANG data tree. |
| 601 | * @return 0 on success, non-zero otherwise. |
| 602 | */ |
| 603 | int nc_server_config_del_tls_keystore_ref(const char *endpt_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 604 | |
| 605 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 606 | * @brief Creates new YANG configuration data nodes for a client's (end-entity) certificate. |
| 607 | * |
roman | 84fc45a | 2024-05-13 15:44:10 +0200 | [diff] [blame] | 608 | * A client certificate is authenticated if it is an exact match to a configured client certificate. |
| 609 | * |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 610 | * @param[in] ctx libyang context. |
| 611 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 612 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 613 | * @param[in] cert_name Arbitrary identifier of the client's certificate. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 614 | * If a client certificate with this identifier already exists, it will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 615 | * @param[in] cert_path Path to the client's certificate file. |
| 616 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 617 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 618 | * @return 0 on success, non-zero otherwise. |
| 619 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 620 | int nc_server_config_add_tls_client_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 621 | const char *cert_path, struct lyd_node **config); |
| 622 | |
| 623 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 624 | * @brief Deletes a client (end-entity) certificate from the YANG data. |
| 625 | * |
| 626 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 627 | * @param[in] cert_name Optional name of a certificate to be deleted. |
| 628 | * If NULL, all of the end-entity certificates on the given endpoint will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 629 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 630 | * @return 0 on success, non-zero otherwise. |
| 631 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 632 | int nc_server_config_del_tls_client_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 633 | |
| 634 | /** |
| 635 | * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client (end-entity) certificates. |
| 636 | * |
| 637 | * @param[in] ctx libyang context. |
| 638 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 639 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 640 | * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced. |
| 641 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 642 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 643 | * @return 0 on success, non-zero otherwise. |
| 644 | */ |
| 645 | int nc_server_config_add_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, |
| 646 | const char *cert_bag_ref, struct lyd_node **config); |
| 647 | |
| 648 | /** |
| 649 | * @brief Deletes a client (end-entity) certificates truststore reference from the YANG data. |
| 650 | * |
| 651 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 652 | * @param[in,out] config Modified configuration YANG data tree. |
| 653 | * @return 0 on success, non-zero otherwise. |
| 654 | */ |
| 655 | int nc_server_config_del_tls_client_cert_truststore_ref(const char *endpt_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 656 | |
| 657 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 658 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 659 | * |
roman | 84fc45a | 2024-05-13 15:44:10 +0200 | [diff] [blame] | 660 | * A client certificate is authenticated if it has a valid chain of trust to any configured CA cert. |
| 661 | * The configured CA cert, up to which the valid chain of trust can be built, does not have to be |
| 662 | * self-signed (the root CA). That means that the chain may be incomplete, yet the client will be authenticated. |
| 663 | * |
| 664 | * For example assume a certificate chain |
| 665 | * A <- B <- C, |
| 666 | * where A is the root CA, then the client certificate C will be authenticated either |
| 667 | * if solely B is configured, or if both A and B are configured. C will not be authenticated |
| 668 | * if just A is configured as a CA certificate. |
| 669 | * |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 670 | * @param[in] ctx libyang context. |
| 671 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 672 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 673 | * @param[in] cert_name Arbitrary identifier of the certificate authority certificate. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 674 | * If a CA with this identifier already exists, it will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 675 | * @param[in] cert_path Path to the CA certificate file. |
| 676 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 677 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 678 | * @return 0 on success, non-zero otherwise. |
| 679 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 680 | int nc_server_config_add_tls_ca_cert(const struct ly_ctx *ctx, const char *endpt_name, const char *cert_name, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 681 | const char *cert_path, struct lyd_node **config); |
| 682 | |
| 683 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 684 | * @brief Deletes a client certificate authority (trust-anchor) certificate from the YANG data. |
| 685 | * |
| 686 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 687 | * @param[in] cert_name Optional name of a certificate to be deleted. |
| 688 | * If NULL, all of the CA certificates on the given endpoint will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 689 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 690 | * @return 0 on success, non-zero otherwise. |
| 691 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 692 | int nc_server_config_del_tls_ca_cert(const char *endpt_name, const char *cert_name, struct lyd_node **config); |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 693 | |
| 694 | /** |
| 695 | * @brief Creates new YANG configuration data nodes for a truststore reference to a set of client certificate authority (trust-anchor) certificates. |
| 696 | * |
| 697 | * @param[in] ctx libyang context. |
| 698 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 699 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 700 | * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced. |
| 701 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 702 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 703 | * @return 0 on success, non-zero otherwise. |
| 704 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 705 | int nc_server_config_add_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *endpt_name, |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 706 | const char *cert_bag_ref, struct lyd_node **config); |
| 707 | |
| 708 | /** |
| 709 | * @brief Deletes a client certificate authority (trust-anchor) certificates truststore reference from the YANG data. |
| 710 | * |
| 711 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 712 | * @param[in,out] config Modified configuration YANG data tree. |
| 713 | * @return 0 on success, non-zero otherwise. |
| 714 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 715 | int nc_server_config_del_tls_ca_cert_truststore_ref(const char *endpt_name, struct lyd_node **config); |
roman | 12c3d52 | 2023-07-26 13:39:30 +0200 | [diff] [blame] | 716 | |
| 717 | /** |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 718 | * @brief Creates new YANG configuration data nodes, which will be a reference to another TLS endpoint's certificates. |
| 719 | * |
| 720 | * Whenever an user tries to connect to the referencing endpoint, all of its certificates will be tried first. If no match is |
| 721 | * found, the referenced endpoint's configured certificates will be tried. The same applies to cert-to-name entries. |
| 722 | * |
| 723 | * @param[in] ctx libyang context |
| 724 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
| 725 | * If an endpoint with this identifier already exists, its contents will be changed. |
| 726 | * @param[in] referenced_endpt Identifier of an endpoint, which has to exist whenever this data |
| 727 | * is applied. The referenced endpoint can reference another one and so on, but there mustn't be a cycle. |
| 728 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 729 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 730 | * @return 0 on success, non-zero otherwise. |
| 731 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 732 | int nc_server_config_add_tls_endpoint_client_ref(const struct ly_ctx *ctx, const char *endpt_name, |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 733 | const char *referenced_endpt, struct lyd_node **config); |
| 734 | |
| 735 | /** |
| 736 | * @brief Deletes reference to another TLS endpoint's users from the YANG data. |
| 737 | * |
| 738 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 739 | * @param[in,out] config Modified configuration YANG data tree. |
| 740 | * @return 0 on success, non-zero otherwise. |
| 741 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 742 | int nc_server_config_del_tls_endpoint_client_ref(const char *endpt_name, struct lyd_node **config); |
Roytak | 7695891 | 2023-09-29 15:25:14 +0200 | [diff] [blame] | 743 | |
| 744 | /** |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 745 | * @brief Creates new YANG configuration data nodes for a cert-to-name entry. |
| 746 | * |
| 747 | * @param[in] ctx libyang context. |
| 748 | * @param[in] endpt_name Arbitrary identifier of the endpoint. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 749 | * If an endpoint with this identifier already exists, its contents will be changed. |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 750 | * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier). |
| 751 | * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is |
| 752 | * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry. |
| 753 | * @param[in] map_type Mapping username to the certificate option. |
| 754 | * @param[in] name Username for this cert-to-name entry. |
| 755 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 756 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 757 | * @return 0 on success, non-zero otherwise. |
| 758 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 759 | int nc_server_config_add_tls_ctn(const struct ly_ctx *ctx, const char *endpt_name, uint32_t id, const char *fingerprint, |
roman | 3f9b65c | 2023-06-05 14:26:58 +0200 | [diff] [blame] | 760 | NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 761 | |
roman | 12644fe | 2023-06-08 11:06:42 +0200 | [diff] [blame] | 762 | /** |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 763 | * @brief Deletes a cert-to-name entry from the YANG data. |
| 764 | * |
| 765 | * @param[in] endpt_name Identifier of an existing endpoint. |
| 766 | * @param[in] id Optional ID of the CTN entry. |
| 767 | * If 0, all of the cert-to-name entries on the given endpoint will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 768 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 769 | * @return 0 on success, non-zero otherwise. |
| 770 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 771 | int nc_server_config_del_tls_ctn(const char *endpt_name, uint32_t id, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 772 | |
| 773 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 774 | * @} TLS Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 775 | */ |
| 776 | |
| 777 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 778 | * @defgroup server_config_ch Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 779 | * @ingroup server_config |
| 780 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 781 | * @brief Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 782 | * @{ |
| 783 | */ |
| 784 | |
| 785 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 786 | * @} Call Home Server Configuration |
| 787 | */ |
| 788 | |
| 789 | /** |
| 790 | * @defgroup server_config_ch_functions Call Home Server Configuration Functions |
| 791 | * @ingroup server_config_ch |
| 792 | * |
| 793 | * @brief Call Home server configuration functions |
| 794 | * @{ |
| 795 | */ |
| 796 | |
| 797 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 798 | * @brief Creates new YANG configuration data nodes for a Call Home client's address and port. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 799 | * |
| 800 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 801 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 802 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 803 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 804 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 805 | * @param[in] transport Transport protocol to be used on this endpoint - either SSH or TLS. |
| 806 | * @param[in] address Address to connect to. |
| 807 | * @param[in] port Port to connect to. |
| 808 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 809 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 810 | * @return 0 on success, non-zero otherwise. |
| 811 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 812 | int nc_server_config_add_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] | 813 | NC_TRANSPORT_IMPL transport, const char *address, const char *port, struct lyd_node **config); |
| 814 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 815 | #endif /* NC_ENABLED_SSH_TLS */ |
| 816 | |
| 817 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 818 | * @brief Deletes a Call Home client from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 819 | * |
| 820 | * @param[in] client_name Optional identifier of a client to be deleted. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 821 | * If NULL, all of the Call Home clients will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 822 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 823 | * @return 0 on success, non-zero otherwise. |
| 824 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 825 | int nc_server_config_del_ch_client(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 826 | |
| 827 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 828 | * @brief Deletes a Call Home endpoint from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 829 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 830 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 831 | * @param[in] endpt_name Optional identifier of a CH endpoint to be deleted. |
| 832 | * If NULL, all of the CH endpoints which belong to the given client will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 833 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 834 | * @return 0 on success, non-zero otherwise. |
| 835 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 836 | int nc_server_config_del_ch_endpt(const char *client_name, const char *endpt_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 837 | |
| 838 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 839 | * @brief Creates new YANG configuration data nodes for the Call Home persistent connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 840 | * |
| 841 | * This is the default connection type. If periodic connection type was set before, it will be unset. |
| 842 | * |
| 843 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 844 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 845 | * If a Call Home client with this identifier already exists, its contents will be changed. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 846 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 847 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 848 | * @return 0 on success, non-zero otherwise. |
| 849 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 850 | int nc_server_config_add_ch_persistent(const struct ly_ctx *ctx, const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 851 | |
| 852 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 853 | * @brief Creates new YANG configuration data nodes for the period parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 854 | * |
| 855 | * If called, the persistent connection type will be replaced by periodic. |
| 856 | * |
| 857 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 858 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 859 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 860 | * @param[in] period Duration between periodic connections in minutes. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 861 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 862 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 863 | * @return 0 on success, non-zero otherwise. |
| 864 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 865 | int nc_server_config_add_ch_period(const struct ly_ctx *ctx, const char *client_name, uint16_t period, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 866 | struct lyd_node **config); |
| 867 | |
| 868 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 869 | * @brief Deletes the Call Home period parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 870 | * |
| 871 | * This behaves the same as setting the period to 60 minutes, which is the default value of this node. |
| 872 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 873 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 874 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 875 | * @return 0 on success, non-zero otherwise. |
| 876 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 877 | int nc_server_config_del_ch_period(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 878 | |
| 879 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 880 | * @brief Creates new YANG configuration data nodes for the anchor time parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 881 | * |
| 882 | * If called, the persistent connection type will be replaced by periodic. |
| 883 | * |
| 884 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 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. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 887 | * @param[in] anchor_time Timestamp before or after which a series of periodic connections are determined. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 888 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 892 | int nc_server_config_add_ch_anchor_time(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 893 | const char *anchor_time, struct lyd_node **config); |
| 894 | |
| 895 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 896 | * @brief Deletes the Call Home anchor time parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 897 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 898 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 899 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 900 | * @return 0 on success, non-zero otherwise. |
| 901 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 902 | int nc_server_config_del_ch_anchor_time(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 903 | |
| 904 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 905 | * @brief Creates new YANG configuration data nodes for the idle timeout parameter of the Call Home periodic connection type. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 906 | * |
| 907 | * If called, the persistent connection type will be replaced by periodic. |
| 908 | * |
| 909 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 910 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 911 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 912 | * @param[in] idle_timeout Specifies the maximum number of seconds that a session may remain idle. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 913 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 914 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 915 | * @return 0 on success, non-zero otherwise. |
| 916 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 917 | int nc_server_config_add_ch_idle_timeout(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 918 | uint16_t idle_timeout, struct lyd_node **config); |
| 919 | |
| 920 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 921 | * @brief Deletes the Call Home idle timeout parameter of the periodic connection type from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 922 | * |
| 923 | * This behaves the same as setting the timeout to 180 seconds, which is the default value of this node. |
| 924 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 925 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 926 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 927 | * @return 0 on success, non-zero otherwise. |
| 928 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 929 | int nc_server_config_del_ch_idle_timeout(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 930 | |
| 931 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 932 | * @brief Creates new YANG configuration data nodes for the Call Home reconnect strategy. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 933 | * |
| 934 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 935 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 936 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 937 | * @param[in] start_with Specifies which endpoint to try if a connection is unsuccessful. Default value is NC_CH_FIRST_LISTED. |
| 938 | * @param[in] max_wait The number of seconds after which a connection to an endpoint is deemed unsuccessful. Default value if 5. |
| 939 | * @param[in] max_attempts The number of unsuccessful connection attempts before moving to the next endpoint. Default value is 3. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 940 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 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 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 944 | int nc_server_config_add_ch_reconnect_strategy(const struct ly_ctx *ctx, const char *client_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 945 | NC_CH_START_WITH start_with, uint16_t max_wait, uint8_t max_attempts, struct lyd_node **config); |
| 946 | |
| 947 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 948 | * @brief Resets the values of the Call Home reconnect strategy nodes to their defaults. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 949 | * |
| 950 | * The default values are: start-with = NC_CH_FIRST_LISTED, max-wait = 5 and max-attempts = 3. |
| 951 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 952 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 953 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 954 | * @return 0 on success, non-zero otherwise. |
| 955 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 956 | int nc_server_config_del_ch_reconnect_strategy(const char *client_name, struct lyd_node **config); |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 957 | |
| 958 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 959 | * @} Call Home Server Configuration Functions |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 960 | */ |
| 961 | |
| 962 | #ifdef NC_ENABLED_SSH_TLS |
| 963 | |
| 964 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 965 | * @defgroup server_config_ch_ssh SSH Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 966 | * @ingroup server_config_ch |
| 967 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 968 | * @brief SSH Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 969 | * @{ |
| 970 | */ |
| 971 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 972 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 973 | * @brief Creates new YANG data nodes for a Call Home SSH hostkey. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 974 | * |
| 975 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 976 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 977 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 978 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 979 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 980 | * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey. |
| 981 | * If the endpoint's hostkey with this identifier already exists, its contents will be changed. |
| 982 | * @param[in] privkey_path Path to a file containing a private key. |
| 983 | * The private key has to be in a PEM format. Only RSA and ECDSA keys are supported. |
| 984 | * @param[in] pubkey_path Path to a file containing a public key. If NULL, public key will be |
| 985 | * generated from the private key. |
| 986 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 987 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 988 | * @return 0 on success, non-zero otherwise. |
| 989 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 990 | int nc_server_config_add_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] | 991 | const char *hostkey_name, const char *privkey_path, const char *pubkey_path, struct lyd_node **config); |
| 992 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 993 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 994 | * @brief Deletes a Call Home hostkey from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 995 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 996 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 997 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 998 | * @param[in] hostkey_name Optional identifier of a hostkey to be deleted. |
| 999 | * If NULL, all of the hostkeys on the given endpoint will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1000 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1001 | * @return 0 on success, non-zero otherwise. |
| 1002 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1003 | int nc_server_config_del_ch_ssh_hostkey(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1004 | const char *hostkey_name, struct lyd_node **config); |
| 1005 | |
| 1006 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1007 | * @brief Creates new YANG data nodes for a reference to an asymmetric key located in the keystore. |
| 1008 | * |
| 1009 | * This asymmetric key pair will be used as the Call Home SSH hostkey. |
| 1010 | * |
| 1011 | * @param[in] ctx libyang context. |
| 1012 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1013 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1014 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1015 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1016 | * @param[in] hostkey_name Arbitrary identifier of the endpoint's hostkey. |
| 1017 | * If the endpoint's hostkey with this identifier already exists, its contents will be changed. |
| 1018 | * @param[in] keystore_reference Name of the asymmetric key pair to be referenced and used as a hostkey. |
| 1019 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1020 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1021 | * @return 0 on success, non-zero otherwise. |
| 1022 | */ |
| 1023 | int nc_server_config_add_ch_ssh_keystore_ref(const struct ly_ctx *ctx, const char *client_name, |
| 1024 | const char *endpt_name, const char *hostkey_name, const char *keystore_reference, struct lyd_node **config); |
| 1025 | |
| 1026 | /** |
| 1027 | * @brief Deletes a Call Home keystore reference from the YANG data. |
| 1028 | * |
| 1029 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1030 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1031 | * @param[in] hostkey_name Identifier of an existing hostkey that belongs to the given CH endpoint. |
| 1032 | * @param[in,out] config Modified configuration YANG data tree. |
| 1033 | * @return 0 on success, non-zero otherwise. |
| 1034 | */ |
| 1035 | int nc_server_config_del_ch_ssh_keystore_ref(const char *client_name, const char *endpt_name, |
| 1036 | const char *hostkey_name, struct lyd_node **config); |
| 1037 | |
| 1038 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1039 | * @brief Creates new YANG data nodes for a Call Home SSH user's public key authentication method. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1040 | * |
| 1041 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1042 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1043 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1044 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1045 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1046 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1047 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
| 1048 | * @param[in] pubkey_name Arbitrary identifier of the user's public key. |
| 1049 | * If the user's public key with this identifier already exists, its contents will be changed. |
| 1050 | * @param[in] pubkey_path Path to a file containing a public key. |
| 1051 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1052 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1053 | * @return 0 on success, non-zero otherwise. |
| 1054 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1055 | int nc_server_config_add_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] | 1056 | const char *user_name, const char *pubkey_name, const char *pubkey_path, struct lyd_node **config); |
| 1057 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1058 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1059 | * @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] | 1060 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1061 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1062 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1063 | * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1064 | * @param[in] pubkey_name Optional identifier of a public key to be deleted. |
| 1065 | * If NULL, all of the public keys which belong to the given SSH user will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1066 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1067 | * @return 0 on success, non-zero otherwise. |
| 1068 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1069 | int nc_server_config_del_ch_ssh_user_pubkey(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1070 | const char *user_name, const char *pubkey_name, struct lyd_node **config); |
roman | 5cbb653 | 2023-06-22 12:53:17 +0200 | [diff] [blame] | 1071 | |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1072 | /** |
roman | a9ec336 | 2023-12-21 10:59:57 +0100 | [diff] [blame] | 1073 | * @brief Creates new YANG configuration data nodes for a Call Home SSH user that will use system's authorized_keys to authenticate. |
| 1074 | * |
| 1075 | * The path to the authorized_keys file must be configured to successfully |
| 1076 | * authenticate, see ::nc_server_ssh_set_authkey_path_format(). |
| 1077 | * |
| 1078 | * @param[in] ctx libyang context. |
| 1079 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1080 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1081 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1082 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1083 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1084 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
| 1085 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1086 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1087 | * @return 0 on success, non-zero otherwise. |
| 1088 | */ |
| 1089 | int nc_server_config_add_ch_ssh_user_authkey(const struct ly_ctx *ctx, const char *client_name, |
| 1090 | const char *endpt_name, const char *user_name, struct lyd_node **config); |
| 1091 | |
| 1092 | /** |
| 1093 | * @brief Deletes a Call Home SSH user's authorized_keys method from the YANG data. |
| 1094 | * |
| 1095 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1096 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1097 | * @param[in] user_name Identifier of an existing user on the given endpoint. |
| 1098 | * @param[in,out] config Modified configuration YANG data tree. |
| 1099 | * @return 0 on success, non-zero otherwise. |
| 1100 | */ |
| 1101 | int nc_server_config_ch_del_ssh_user_authkey(const char *client_name, const char *endpt_name, |
| 1102 | const char *user_name, struct lyd_node **config); |
| 1103 | |
| 1104 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1105 | * @brief Creates new YANG data nodes for a Call Home SSH user's password authentication method. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1106 | * |
| 1107 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1108 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1109 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1110 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1111 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1112 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1113 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 1114 | * @param[in] password Clear-text password to be set for the user. It will be hashed. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1115 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1116 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1117 | * @return 0 on success, non-zero otherwise. |
| 1118 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1119 | int nc_server_config_add_ch_ssh_user_password(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1120 | const char *user_name, const char *password, struct lyd_node **config); |
| 1121 | |
| 1122 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1123 | * @brief Deletes a Call Home SSH user's password from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1124 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1125 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1126 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1127 | * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint. |
| 1128 | * @param[in,out] config Modified configuration YANG data tree. |
| 1129 | * @return 0 on success, non-zero otherwise. |
| 1130 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1131 | int nc_server_config_del_ch_ssh_user_password(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1132 | const char *user_name, struct lyd_node **config); |
| 1133 | |
| 1134 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1135 | * @brief Creates new YANG configuration data nodes for a Call Home SSH user's keyboard interactive authentication method. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1136 | * |
roman | c651842 | 2023-11-30 16:39:00 +0100 | [diff] [blame] | 1137 | * One of Linux PAM, local users, or user callback is used to authenticate users with this SSH method (see \ref ln2doc_kbdint "the documentation"). |
roman | 808f3f6 | 2023-11-23 16:01:04 +0100 | [diff] [blame] | 1138 | * |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1139 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1140 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1141 | * If a Call Home client with this identifier already exists, its contents will be changed. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1142 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1143 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1144 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1145 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1146 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1147 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1148 | * @return 0 on success, non-zero otherwise. |
| 1149 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1150 | int nc_server_config_add_ch_ssh_user_interactive(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | 808f3f6 | 2023-11-23 16:01:04 +0100 | [diff] [blame] | 1151 | const char *user_name, struct lyd_node **config); |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1152 | |
| 1153 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1154 | * @brief Deletes a Call Home SSH user's keyboard interactive authentication from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1155 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1156 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1157 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1158 | * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint. |
| 1159 | * @param[in,out] config Modified configuration YANG data tree. |
| 1160 | * @return 0 on success, non-zero otherwise. |
| 1161 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1162 | int nc_server_config_del_ch_ssh_user_interactive(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1163 | const char *user_name, struct lyd_node **config); |
| 1164 | |
| 1165 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1166 | * @brief Deletes a Call Home SSH user from the YANG data. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1167 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1168 | * @param[in] client_name Identifier of an existing Call Home client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1169 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1170 | * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint. |
| 1171 | * @param[in,out] config Modified configuration YANG data tree. |
| 1172 | * @return 0 on success, non-zero otherwise. |
| 1173 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1174 | int nc_server_config_del_ch_ssh_user(const char *client_name, const char *endpt_name, |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1175 | const char *user_name, struct lyd_node **config); |
| 1176 | |
| 1177 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1178 | * @brief Creates new YANG data nodes for a reference to a public key bag located in the truststore. |
| 1179 | * |
| 1180 | * The public key's located in the bag will be used for Call Home SSH client authentication. |
| 1181 | * |
| 1182 | * @param[in] ctx libyang context. |
| 1183 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1184 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1185 | * @param[in] endpt_name Arbitrary identifier of the client's endpoint. |
| 1186 | * If the client's endpoint with this identifier already exists, its contents will be changed. |
| 1187 | * @param[in] user_name Arbitrary identifier of the endpoint's user. |
| 1188 | * If the endpoint's user with this identifier already exists, its contents will be changed. |
| 1189 | * @param[in] truststore_reference Name of the public key bag to be referenced and used for authentication. |
| 1190 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1191 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1192 | * @return 0 on success, non-zero otherwise. |
| 1193 | */ |
| 1194 | int nc_server_config_add_ch_ssh_truststore_ref(const struct ly_ctx *ctx, const char *client_name, |
| 1195 | const char *endpt_name, const char *user_name, const char *truststore_reference, struct lyd_node **config); |
| 1196 | |
| 1197 | /** |
| 1198 | * @brief Deletes a Call Home SSH truststore reference from the YANG data. |
| 1199 | * |
| 1200 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1201 | * @param[in] endpt_name Identifier of an existing endpoint that belongs to the given CH client. |
| 1202 | * @param[in] user_name Identifier of an existing SSH user that belongs to the given CH endpoint. |
| 1203 | * @param[in,out] config Modified configuration YANG data tree. |
| 1204 | * @return 0 on success, non-zero otherwise. |
| 1205 | */ |
| 1206 | int nc_server_config_del_ch_ssh_truststore_ref(const char *client_name, const char *endpt_name, |
| 1207 | const char *user_name, struct lyd_node **config); |
| 1208 | |
| 1209 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 1210 | * @} SSH Call Home Server Configuration |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1211 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1212 | |
| 1213 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1214 | * @defgroup server_config_ch_tls TLS Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1215 | * @ingroup server_config_ch |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1216 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1217 | * @brief TLS Call Home server configuration creation and deletion |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1218 | * @{ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1219 | */ |
roman | 142718b | 2023-06-29 09:15:29 +0200 | [diff] [blame] | 1220 | |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1221 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1222 | * @brief Creates new YANG configuration data nodes for a Call Home server's certificate. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1223 | * |
| 1224 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1225 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1226 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1227 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1228 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
roman | 6c4efcd | 2023-08-08 10:18:44 +0200 | [diff] [blame] | 1229 | * @param[in] privkey_path Path to the server's PEM encoded private key file. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1230 | * @param[in] pubkey_path Optional path to the server's public key file. If not provided, |
| 1231 | * it will be generated from the private key. |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1232 | * @param[in] cert_path Path to the server's certificate file. |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1233 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1234 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1235 | * @return 0 on success, non-zero otherwise. |
| 1236 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1237 | int nc_server_config_add_ch_tls_server_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
| 1238 | const char *privkey_path, const char *pubkey_path, const char *cert_path, struct lyd_node **config); |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1239 | |
| 1240 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1241 | * @brief Deletes a Call Home server certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1242 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1243 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1244 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1245 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1246 | * @return 0 on success, non-zero otherwise. |
| 1247 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1248 | int nc_server_config_del_ch_tls_server_cert(const char *client_name, const char *endpt_name, |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1249 | struct lyd_node **config); |
| 1250 | |
| 1251 | /** |
| 1252 | * @brief Creates new YANG configuration data nodes for a keystore reference to the Call Home TLS server's certificate. |
| 1253 | * |
| 1254 | * @param[in] ctx libyang context. |
| 1255 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1256 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1257 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1258 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
| 1259 | * @param[in] asym_key_ref Name of the asymmetric key pair in the keystore to be referenced. |
| 1260 | * @param[in] cert_ref Name of the certificate, which must belong to the given asymmetric key pair, to be referenced. |
| 1261 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1262 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1263 | * @return 0 on success, non-zero otherwise. |
| 1264 | */ |
| 1265 | int nc_server_config_add_ch_tls_keystore_ref(const struct ly_ctx *ctx, const char *client_name, |
| 1266 | const char *endpt_name, const char *asym_key_ref, const char *cert_ref, struct lyd_node **config); |
| 1267 | |
| 1268 | /** |
| 1269 | * @brief Deletes a TLS server certificate keystore reference from the YANG data. |
| 1270 | * |
| 1271 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1272 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
| 1273 | * @param[in,out] config Modified configuration YANG data tree. |
| 1274 | * @return 0 on success, non-zero otherwise. |
| 1275 | */ |
| 1276 | int nc_server_config_del_ch_tls_keystore_ref(const char *client_name, const char *endpt_name, |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1277 | struct lyd_node **config); |
| 1278 | |
| 1279 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1280 | * @brief Creates new YANG configuration data nodes for a Call Home client's (end-entity) certificate. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1281 | * |
| 1282 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1283 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1284 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1285 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1286 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
| 1287 | * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's end-entity certificate. |
| 1288 | * If an Call Home endpoint's end-entity certificate with this identifier already exists, its contents will be changed. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1289 | * @param[in] cert_path Path to the certificate file. |
Roytak | 934edc3 | 2023-07-27 12:04:18 +0200 | [diff] [blame] | 1290 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1291 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1292 | * @return 0 on success, non-zero otherwise. |
| 1293 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1294 | int nc_server_config_add_ch_tls_client_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1295 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1296 | |
| 1297 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1298 | * @brief Deletes a Call Home client (end-entity) certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1299 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1300 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1301 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1302 | * @param[in] cert_name Optional identifier of a client certificate to be deleted. |
| 1303 | * If NULL, all of the client certificates will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1304 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1305 | * @return 0 on success, non-zero otherwise. |
| 1306 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1307 | int nc_server_config_del_ch_tls_client_cert(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1308 | const char *cert_name, struct lyd_node **config); |
| 1309 | |
| 1310 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1311 | * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client (end-entity) certificates. |
| 1312 | * |
| 1313 | * @param[in] ctx libyang context. |
| 1314 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1315 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1316 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1317 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
| 1318 | * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced. |
| 1319 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1320 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1321 | * @return 0 on success, non-zero otherwise. |
| 1322 | */ |
| 1323 | int nc_server_config_add_ch_tls_client_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name, |
| 1324 | const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config); |
| 1325 | |
| 1326 | /** |
| 1327 | * @brief Deletes a Call Home client (end-entity) certificates truststore reference from the YANG data. |
| 1328 | * |
| 1329 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1330 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
| 1331 | * @param[in,out] config Modified configuration YANG data tree. |
| 1332 | * @return 0 on success, non-zero otherwise. |
| 1333 | */ |
| 1334 | int nc_server_config_del_ch_tls_client_cert_truststore_ref(const char *client_name, const char *endpt_name, |
| 1335 | struct lyd_node **config); |
| 1336 | |
| 1337 | /** |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1338 | * @brief Creates new YANG configuration data nodes for a client certificate authority (trust-anchor) certificate. |
| 1339 | * |
| 1340 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1341 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1342 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1343 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1344 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
| 1345 | * @param[in] cert_name Arbitrary identifier of the Call Home endpoint's certificate authority certificate. |
| 1346 | * If an Call Home endpoint's CA certificate with this identifier already exists, its contents will be changed. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1347 | * @param[in] cert_path Path to the certificate file. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 1348 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1349 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1350 | * @return 0 on success, non-zero otherwise. |
| 1351 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1352 | int nc_server_config_add_ch_tls_ca_cert(const struct ly_ctx *ctx, const char *client_name, const char *endpt_name, |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1353 | const char *cert_name, const char *cert_path, struct lyd_node **config); |
| 1354 | |
| 1355 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1356 | * @brief Deletes a Call Home client certificate authority (trust-anchor) certificate from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1357 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1358 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1359 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1360 | * @param[in] cert_name Optional identifier of a CA certificate to be deleted. |
| 1361 | * If NULL, all of the CA certificates will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1362 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1363 | * @return 0 on success, non-zero otherwise. |
| 1364 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1365 | int nc_server_config_del_ch_tls_ca_cert(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1366 | const char *cert_name, struct lyd_node **config); |
| 1367 | |
| 1368 | /** |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1369 | * @brief Creates new YANG configuration data nodes for a Call Home truststore reference to a set of client certificate authority (trust-anchor) certificates. |
| 1370 | * |
| 1371 | * @param[in] ctx libyang context. |
| 1372 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1373 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1374 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1375 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
| 1376 | * @param[in] cert_bag_ref Identifier of the certificate bag in the truststore to be referenced. |
| 1377 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
| 1378 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1379 | * @return 0 on success, non-zero otherwise. |
| 1380 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1381 | int nc_server_config_add_ch_tls_ca_cert_truststore_ref(const struct ly_ctx *ctx, const char *client_name, |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1382 | const char *endpt_name, const char *cert_bag_ref, struct lyd_node **config); |
| 1383 | |
| 1384 | /** |
| 1385 | * @brief Deletes a Call Home client certificate authority (trust-anchor) certificates truststore reference from the YANG data. |
| 1386 | * |
| 1387 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1388 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
| 1389 | * @param[in,out] config Modified configuration YANG data tree. |
| 1390 | * @return 0 on success, non-zero otherwise. |
| 1391 | */ |
roman | e6ec60e | 2023-10-19 15:21:52 +0200 | [diff] [blame] | 1392 | int nc_server_config_del_ch_tls_ca_cert_truststore_ref(const char *client_name, const char *endpt_name, |
roman | d348b94 | 2023-10-13 14:32:19 +0200 | [diff] [blame] | 1393 | struct lyd_node **config); |
| 1394 | |
| 1395 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1396 | * @brief Creates new YANG configuration data nodes for a Call Home cert-to-name entry. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1397 | * |
| 1398 | * @param[in] ctx libyang context. |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1399 | * @param[in] client_name Arbitrary identifier of the Call Home client. |
| 1400 | * If a Call Home client with this identifier already exists, its contents will be changed. |
| 1401 | * @param[in] endpt_name Arbitrary identifier of the Call Home client's endpoint. |
| 1402 | * If a Call Home client's endpoint with this identifier already exists, its contents will be changed. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1403 | * @param[in] id ID of the entry. The lower the ID, the higher the priority of the entry (it will be checked earlier). |
| 1404 | * @param[in] fingerprint Optional fingerprint of the entry. The fingerprint should always be set, however if it is |
| 1405 | * not set, it will match any certificate. Entry with no fingerprint should therefore be placed only as the last entry. |
| 1406 | * @param[in] map_type Mapping username to the certificate option. |
| 1407 | * @param[in] name Username for this cert-to-name entry. |
Roytak | 9b32c0f | 2023-08-02 15:07:29 +0200 | [diff] [blame] | 1408 | * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created. |
roman | b6f4403 | 2023-06-30 15:07:56 +0200 | [diff] [blame] | 1409 | * Otherwise the new YANG data will be added to the previous data and may override it. |
| 1410 | * @return 0 on success, non-zero otherwise. |
| 1411 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1412 | int nc_server_config_add_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] | 1413 | uint32_t id, const char *fingerprint, NC_TLS_CTN_MAPTYPE map_type, const char *name, struct lyd_node **config); |
| 1414 | |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1415 | /** |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1416 | * @brief Deletes a Call Home cert-to-name entry from the YANG data. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1417 | * |
Roytak | 2161df6 | 2023-08-02 15:04:42 +0200 | [diff] [blame] | 1418 | * @param[in] client_name Identifier of an existing Call Home client. |
| 1419 | * @param[in] endpt_name Identifier of an existing Call Home endpoint that belongs to the given client. |
| 1420 | * @param[in] id Optional identifier of the Call Home CTN entry to be deleted. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1421 | * If 0, all of the CTN entries will be deleted. |
roman | 9d5e5a5 | 2023-07-14 12:43:44 +0200 | [diff] [blame] | 1422 | * @param[in,out] config Modified configuration YANG data tree. |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1423 | * @return 0 on success, non-zero otherwise. |
| 1424 | */ |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 1425 | int nc_server_config_del_ch_tls_ctn(const char *client_name, const char *endpt_name, |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1426 | uint32_t id, struct lyd_node **config); |
| 1427 | |
| 1428 | /** |
roman | 3512097 | 2023-08-08 10:39:12 +0200 | [diff] [blame] | 1429 | * @} TLS Call Home Server Configuration |
roman | 8ba6efa | 2023-07-12 15:27:52 +0200 | [diff] [blame] | 1430 | */ |
| 1431 | |
roman | 2eab474 | 2023-06-06 10:00:26 +0200 | [diff] [blame] | 1432 | #endif /* NC_ENABLED_SSH_TLS */ |
roman | 45cec4e | 2023-02-17 10:21:39 +0100 | [diff] [blame] | 1433 | |
roman | c1d2b09 | 2023-02-02 08:58:27 +0100 | [diff] [blame] | 1434 | #ifdef __cplusplus |
| 1435 | } |
| 1436 | #endif |
| 1437 | |
| 1438 | #endif /* NC_SESSION_SERVER_H_ */ |