Skip to content

Commit 25b28db

Browse files
committed
server config UPDATE allow unsupported keys
Do not fail when an unsupported key format is encountered. Instead just possibly fail if it were to be used. Fixes #563
1 parent 221b95d commit 25b28db

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/server_config.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,10 @@ config_pubkey_format(const struct lyd_node *node, enum nc_operation parent_op, s
745745
} else if (!strcmp(format, "subject-public-key-info-format")) {
746746
pubkey->type = NC_PUBKEY_FORMAT_X509;
747747
} else {
748-
ERR(NULL, "Unknown public key format \"%s\".", format);
749-
return 1;
748+
/* do not fail, the key may still be usable, or it may have come from a keystore/truststore
749+
* and have a different purpose other than NETCONF */
750+
WRN(NULL, "Public key format \"%s\" not supported. The key may not be usable.", format);
751+
pubkey->type = NC_PUBKEY_FORMAT_UNKNOWN;
750752
}
751753
}
752754

@@ -795,8 +797,10 @@ config_privkey_format(const struct lyd_node *node, enum nc_operation parent_op,
795797
} else if (!strcmp(format, "openssh-private-key-format")) {
796798
privkey->type = NC_PRIVKEY_FORMAT_OPENSSH;
797799
} else {
798-
ERR(NULL, "Unknown private key format \"%s\".", format);
799-
return 1;
800+
/* do not fail, the key may still be usable, or it may have come from a keystore/truststore
801+
* and have a different purpose other than NETCONF */
802+
WRN(NULL, "Private key format \"%s\" not supported. The key may not be usable.", format);
803+
privkey->type = NC_PRIVKEY_FORMAT_UNKNOWN;
800804
}
801805
}
802806

tests/test_config.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ test_config_all_nodes(void **state)
786786
ret = nc_server_config_setup_diff(dup);
787787
assert_int_equal(ret, 0);
788788

789+
free(mem);
790+
free(mem_filled);
789791
lyd_free_all(dup);
790792
lyd_free_all(tree);
791793
}
@@ -968,6 +970,7 @@ main(void)
968970
cmocka_unit_test_setup_teardown(test_preserve_conn, setup_f, ln2_glob_test_teardown),
969971
cmocka_unit_test_setup_teardown(test_transport_params_oper_get, setup_f, ln2_glob_test_teardown),
970972
cmocka_unit_test_setup_teardown(test_config_all_nodes, setup_f, ln2_glob_test_teardown),
973+
cmocka_unit_test_setup_teardown(test_unusupported_asymkey_format, setup_f, ln2_glob_test_teardown),
971974
};
972975

973976
/* try to get ports from the environment, otherwise use the default */

0 commit comments

Comments
 (0)