From nobody Fri May 20 21:59:41 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 26F661AE7517; Fri, 20 May 2022 21:59:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L4gcZ0Zhwz3t58; Fri, 20 May 2022 21:59:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653083982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d3bw/aun2b+fS+FVZUGMC/xlSCSzaqRKaYPdCn+IHiU=; b=edvipB2/xAGMnXG2Y+DcdUY9uN5UdS6j3rkS9TA3PcF5Wdmc5a+0dw2cypTogbpq0qJIEe MauOHRUkAupSHYiZfZb2L6uLJhh4cBa7IOiT+5kQmQOBFZJfUCkQVTYCcfAoICVj+cshac AWXoBYRLkyD2ldqcrFsAII6qO5GTboYQ24r/vo3Wj7tjz3DbVIr4qUUwIMLJnDTlLMPquT +K/MVMfipfQincTWgG9ftX2iehFfIE8HmG+RYDO9ygc3bmODnVyqjlD8CuMH4teccQmKkd XkkI8Rw2BiMfazsgC2Vz7kXpQ+7jMNyhRjSRMKIjPJSCJsEWjOI3VyVrPv3TeQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E48051A355; Fri, 20 May 2022 21:59:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24KLxf83023372; Fri, 20 May 2022 21:59:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24KLxfYd023371; Fri, 20 May 2022 21:59:41 GMT (envelope-from git) Date: Fri, 20 May 2022 21:59:41 GMT Message-Id: <202205202159.24KLxfYd023371@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 72bf76d6b8c9 - main - rpc.tlsclntd: Add an option to force use of TLS version 1.2 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72bf76d6b8c9e9de81661b68389e0035805b8606 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653083982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d3bw/aun2b+fS+FVZUGMC/xlSCSzaqRKaYPdCn+IHiU=; b=UI4nYxYgO2RWnlVs2jMWE+HlX2XuTW3tLSQwaOfN5J1QUX2IPfu/oOy2yYYY8GsRjMbIjV LKbB3h/ZaIyWCYCTGKtnVzQk0MU+Up7FinXT1ROgQ3MVCsLUCL88c6Z4YXN0RqQvTuWbtW qoaLqND/Z+SmYuy0w/MY0xWAw/Nl0PO8XAmVO9NeqmQInDkNYZ7vvBRODAAMnToxF88NiA 8LrVV+aYjehkq+evhFB6KDdhiYPXRIOQ0J5Xs/ehr/UQ3gvD/cX1VprriZut4wfiQQDfUR BH3lYkAyIylpY4nM4UrQ5cAFmOMFZCbO913zrvY73zh4mjgTDISWKJBDInxQ4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653083982; a=rsa-sha256; cv=none; b=DeM2ylluK+GzeTgp/EzS7sVnEpcr9/ANvPYfBttoq0rmxefw3jQo6MGc4eowfSXRvhRS3/ Ai81oTDoAGY3aqck9HhHld+fzmOurgTC21PNgro2Z5c8pzuQWKA6IxRiSCajA1BlKjOnuD 6y06bbVK+ssjuvSl+FUXxP8JewvsPGST8MVl3+q1R8Y2xTNMD2QHA1nbDc0agd7zDeVLQH AYewblQTuroMKeEeHTHc8/cmAW/Pm/QkLPbV52OhhOjr/vZOG8ly4VTzr7S80dxICY+zK+ z84bKoe5wb081eiGrubLkS3h2rr0ULAsNV41Jbbsdy+NnGStlgmDqpDpHPd5rA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=72bf76d6b8c9e9de81661b68389e0035805b8606 commit 72bf76d6b8c9e9de81661b68389e0035805b8606 Author: Rick Macklem AuthorDate: 2022-05-20 21:57:42 +0000 Commit: Rick Macklem CommitDate: 2022-05-20 21:57:42 +0000 rpc.tlsclntd: Add an option to force use of TLS version 1.2 Commit 0b4f2ab0e913 fixes the krpc so that it can use TLS version 1.3 for NFS-over-TLS, as required by the draft (someday to be an RFC). Since FreeBSD 13.0, 13.1 use TLS version 1.2 for NFS-over-TLS mounts, this command line option may be used so that NFS-over-TLS mounts to 13.0, 13.1 servers will still work. Without the command line option, NFS-over-TLS mounts will use TLS version 1.3. The man page update will be a separate commit. MFC after: 2 weeks --- usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c | 39 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c index ac8a91589388..f650c42c539d 100644 --- a/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c +++ b/usr.sbin/rpc.tlsclntd/rpc.tlsclntd.c @@ -96,6 +96,7 @@ static const char *rpctls_ciphers = NULL; static uint64_t rpctls_ssl_refno = 0; static uint64_t rpctls_ssl_sec = 0; static uint64_t rpctls_ssl_usec = 0; +static int rpctls_tlsvers = TLS1_3_VERSION; static void rpctlscd_terminate(int); static SSL_CTX *rpctls_setupcl_ssl(void); @@ -106,6 +107,7 @@ static void rpctls_huphandler(int sig __unused); extern void rpctlscd_1(struct svc_req *rqstp, SVCXPRT *transp); static struct option longopts[] = { + { "usetls1_2", no_argument, NULL, '2' }, { "certdir", required_argument, NULL, 'D' }, { "ciphers", required_argument, NULL, 'C' }, { "debuglevel", no_argument, NULL, 'd' }, @@ -154,9 +156,12 @@ main(int argc, char **argv) rpctls_ssl_usec = tm.tv_usec; rpctls_verbose = false; - while ((ch = getopt_long(argc, argv, "C:D:dl:mp:r:v", longopts, + while ((ch = getopt_long(argc, argv, "2C:D:dl:mp:r:v", longopts, NULL)) != -1) { switch (ch) { + case '2': + rpctls_tlsvers = TLS1_2_VERSION; + break; case 'C': rpctls_ciphers = optarg; break; @@ -463,7 +468,6 @@ static SSL_CTX * rpctls_setupcl_ssl(void) { SSL_CTX *ctx; - long flags; char path[PATH_MAX]; size_t len, rlen; int ret; @@ -567,17 +571,30 @@ rpctls_setupcl_ssl(void) SSL_load_client_CA_file(rpctls_verify_cafile)); } - /* RPC-over-TLS must use TLSv1.3, according to the IETF draft.*/ -#ifdef notyet - flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | - SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; -#else - flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1_3; -#endif + /* + * The RFC specifies that RPC-over-TLS must use TLS1.3. + * However, early FreeBSD versions (13.0, 13.1) did not + * support RX for KTLS1.3, so TLS1.2 needs to be used for + * these servers. + */ + ret = SSL_CTX_set_min_proto_version(ctx, rpctls_tlsvers); + if (ret == 0) { + rpctls_verbose_out("rpctls_setupcl_ssl: " + "SSL_CTX_set_min_proto_version failed\n"); + SSL_CTX_free(ctx); + return (NULL); + } + ret = SSL_CTX_set_max_proto_version(ctx, rpctls_tlsvers); + if (ret == 0) { + rpctls_verbose_out("rpctls_setupcl_ssl: " + "SSL_CTX_set_max_proto_version failed\n"); + SSL_CTX_free(ctx); + return (NULL); + } + #ifdef SSL_OP_ENABLE_KTLS - flags |= SSL_OP_ENABLE_KTLS; + SSL_CTX_set_options(ctx, SSL_OP_ENABLE_KTLS); #endif - SSL_CTX_set_options(ctx, flags); #ifdef SSL_MODE_NO_KTLS_TX SSL_CTX_clear_mode(ctx, SSL_MODE_NO_KTLS_TX | SSL_MODE_NO_KTLS_RX); #endif