Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2022-06-12 12:04:26 +0300
committerSimon Tatham <anakin@pobox.com>2022-06-25 16:32:23 +0300
commitf579b3c01e2bfd439d493be06b934404e13d3376 (patch)
treec89254e418d4536417c55c85a42430b360887620 /ssh/transport2.c
parent08d58fe13e84a929c72c5d4aa98001279463a79f (diff)
Certificate trust scope: change to a boolean-expression system.
This replaces the previous placeholder scheme of having a list of hostname wildcards with implicit logical-OR semantics (if any wildcard matched then the certificate would be trusted to sign for that host). That scheme didn't allow for exceptions within a domain ('everything in example.com except extra-high-security-machine.example.com'), and also had no way to specify port numbers. In the new system, you can still write a hostname wildcard by itself in the simple case, but now those are just atomic subexpressions in a boolean-logic domain-specific language I've made up. So if you want multiple wildcards, you can separate them with || in a single longer expression, and also you can use && and ! to impose exceptions on top of that. Full details of the expression language are in the comment at the top of utils/cert-expr.c. It'll need documenting properly before release, of course. For the sake of backwards compatibility for early adopters who've already set up configuration in the old system, I've put in some code that will read the old MatchHosts configuration and automatically translate it into the equivalent boolean expression (by simply stringing together the list of wildcards with || between them).
Diffstat (limited to 'ssh/transport2.c')
-rw-r--r--ssh/transport2.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/ssh/transport2.c b/ssh/transport2.c
index 1d30f240..4383bb98 100644
--- a/ssh/transport2.c
+++ b/ssh/transport2.c
@@ -690,16 +690,9 @@ static void ssh2_write_kexinit_lists(
if (!hca)
continue;
- bool match = false;
- for (size_t i = 0, e = hca->n_hostname_wildcards;
- i < e; i++) {
- if (wc_match(hca->hostname_wildcards[i], hk_host)) {
- match = true;
- break;
- }
- }
-
- if (match && hca->ca_public_key) {
+ if (hca->ca_public_key &&
+ cert_expr_match_str(hca->validity_expression,
+ hk_host, hk_port)) {
accept_certs = true;
add234(host_cas, hca);
} else {