From patchwork Thu Feb 27 16:09:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 868974 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1561:b0:38f:210b:807b with SMTP id 1csp339966wrz; Thu, 27 Feb 2025 08:10:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU4iL/hypfvITlfxIiCBP8+xU90kYujuDNqsHlTlQCEdxDOBErZnefTjqWFcSuWpzqedxaCYg==@linaro.org X-Google-Smtp-Source: AGHT+IFq0M6H7PIU1LJUvYr2Lujht8glK/VkJsr9uhSwdlhSVU+NhJoBvUzeeLlFoJYzjA4Kgues X-Received: by 2002:a17:907:9690:b0:ab7:cd83:98b6 with SMTP id a640c23a62f3a-abf261f96d8mr523966b.6.1740672601245; Thu, 27 Feb 2025 08:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1740672601; cv=none; d=google.com; s=arc-20240605; b=jEger8LI/DTNNt29xiIfM86g2L12i9uxqV7rkH9/CCuB27woxO0+OL/MpzXd8K7UqU DVKaNDujNmVXl4HcoyiMFLXPE6c9cZcJ2/0kmc96q+tFCKRbLwJLI64n5NodT9eqx0ld cDjz8N2RX+Q+FgD64s4eVy1RLiWKx0WQQt+6oVDQDd3rNhU3TVqEdnOdfLdDACgojEQ0 ea2Le/5TrnU9dxqeGO8AJIcfabqNtiO98PvdZ4ItjaedL82PaDl0rsGGsuzv4nfoF0Kt eeR7ejIJsZMxryaU6pZFpm0iJxud4jdCV3Nuzw7SDcWDqzozYRQ5zwvv15gnmtBE+oqT z2Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nTbwl3F9OXzHhhDZT6BDLFMulx1o2E75GIczBDbdv8A=; fh=fg4LVIfV3Czg8uvW+fGOIorR7ZZ+p3HapcCebnt7RUs=; b=ThC7LK8EImZUpuZ2RHtXWvLK5dkCpOusPa1fpAE1y2CSJ1/KByC9wj0OsqrFDWoGkT hXmSKKO3gDfTLEx49LvWaFj5av3TjOrwrJ4jEx8fwB9b3jK2+new3Bg/D8YULfTZ1oJj OMxpyDfhVkbAi+7Ch4hxRMSjM/8tijjyIzLkFufhOXnmp9Uo1VzLhzQhnDhRv2zrxx6l BTzk6UC4msWZ3I/2nqrFeE2kDHlm7cOSOg3nAMDnMjPLhMY7rrD39njbIcI+h17lzpVB FLkRZTWUo7bof7dplp9stBsCC+hcjQqCwJJ96ibulBKGml1QaHLlnuGdb7bq2Bme9arf ixaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lyt4ugn9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-abf15bcc1d7si121276466b.290.2025.02.27.08.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 08:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lyt4ugn9; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08DF3811C5; Thu, 27 Feb 2025 17:09:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Lyt4ugn9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1317811B3; Thu, 27 Feb 2025 17:09:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8302F81115 for ; Thu, 27 Feb 2025 17:09:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4394a823036so11752235e9.0 for ; Thu, 27 Feb 2025 08:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1740672573; x=1741277373; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nTbwl3F9OXzHhhDZT6BDLFMulx1o2E75GIczBDbdv8A=; b=Lyt4ugn9S9FwCH5nTn4Bhz4T5i/hFOkSOgrVso8UyqLjtVBxlvoRQ/DjYz1NsxS7Ix Al2XCl4fq8+gK9kiMhxbjUTTer7WL9I99m1Q1o630t0091kzG2L64oXhmYksQsu/cOYf hD2NYmU/VC10yljVeXW2nYdKygn9FhbLhFDqpCNRWxvZtrAxLT67irv7tTnl6EiyFnQL q5RCvkR+ZV3zIFMwH5GBNeChIiGPcyVPf8j36ARjClOzE7YeZZRDg1PPG8HYM9ch+omB vKKqKoE67rnhD4CkElQ03PsToWlTMEjO2cqAsJ7S3hHkEV4pjU+sJfWXDmZX5SbYfQVT y5cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740672573; x=1741277373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nTbwl3F9OXzHhhDZT6BDLFMulx1o2E75GIczBDbdv8A=; b=HyKmy8CDxjykaZpLLV7e/p6s8fMNR0QDFHUxEyXeH8I6hr4+heYyh/BGkqFthgrlMd 1Bez/4XZOOCvtrJriTGi6dzIawXc5+JVaz+slHijWE1nkO6qCsFK6x4P+VnYBQuluGpe Deo4YMzJRJLzOOiJ9TvOPj90353bsMuhkLZT5uiqHx93Jz7opzq8ByoCSFqqjkJ6bqw0 jJO7chnduUHu2cZyFXhmiMk0XTYEtV00Hs6C6+Q4ul6C8HcndsnwzuF9WhoZl8UhaTHB nVWGGx1dHZuOnZy1dAnJLZWYyvnfNlnHXe4SdHdPp03yBkMlSX49zXEC6dXMqhl++pW1 uwjw== X-Gm-Message-State: AOJu0YyTyCxev1Xg98HU3u2DGZV/q50q5lNmSXp5U60/THc9OryymaXb 06D4iVCEjQbioaMDHpEpczgyvd1/yDvlGu4t8ugC8dXd8dCqWE1mPDeolRuz9rEGy7nPIHdcwBp ghHk= X-Gm-Gg: ASbGncvLGN1AC5FCe1GcnuG94URc4HYv8RPGBsxmwgTzsQr9X6mtsJanVppQVpHM+Dv SrNPjMKdqY4XoPNmaHas5uxfd5ygLiPDj4xS9GhCzliVZqkjInOnwMDJyVLtQG6sS49G0W3tx8Z GfsygkaiE2DjqGTfv3GVkM+9vWGKEArBovVcRxQmJmS04DVvV6HUqx0CaRZsOZQp4Lc5PcHi0Nf rdOmzJHu3uOvr8oM3+8MS2Q9D4m/mU+t/I7nheAze+GrB/lmdOtDk2fJQX6OU7ixuXd6UfTh/OZ cfNFvmVI+jl1Idrqz3e7e+CB/pgSI/c4aBk= X-Received: by 2002:a05:600c:3ca1:b0:439:9595:c8e7 with SMTP id 5b1f17b1804b1-439aea9d78bmr244851715e9.0.1740672572679; Thu, 27 Feb 2025 08:09:32 -0800 (PST) Received: from builder.. ([2a01:e0a:3cb:7bb0:af71:dfb2:66ef:80c3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43aba52b925sm59506795e9.7.2025.02.27.08.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 08:09:32 -0800 (PST) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Jerome Forissier , Tom Rini , Javier Tia , Heinrich Schuchardt Subject: [PATCH 3/5] lwip: tls: warn when no CA exists amd log certificate validation errors Date: Thu, 27 Feb 2025 17:09:03 +0100 Message-ID: <13cea41b33f62ddbd606a926bd1f79ddff8569fb.1740672437.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Using HTTPS without root (CA) certificates is a security issue. Print a warning in this case. Also, when certificate verification fail, print an additional message because "HTTP client error 4" is not very informative (4 is HTTPC_RESULT_ERR_CLOSED). Signed-off-by: Jerome Forissier --- lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c index fa3d1d74fed..ef51a5ac168 100644 --- a/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/lib/lwip/lwip/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -298,6 +298,9 @@ altcp_mbedtls_lower_recv_process(struct altcp_pcb *conn, altcp_mbedtls_state_t * if (ret != 0) { LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_handshake failed: %d\n", ret)); /* handshake failed, connection has to be closed */ + if (ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) { + printf("Certificate verification failed\n"); + } if (conn->err) { conn->err(conn->arg, ERR_CLSD); } @@ -841,6 +844,9 @@ altcp_tls_create_config(int is_server, u8_t cert_count, u8_t pkey_count, int hav altcp_mbedtls_free_config(conf); return NULL; } + if (authmode == MBEDTLS_SSL_VERIFY_NONE) { + printf("WARNING: no CA certificates, HTTPS connections not authenticated\n"); + } mbedtls_ssl_conf_authmode(&conf->conf, authmode); mbedtls_ssl_conf_rng(&conf->conf, mbedtls_ctr_drbg_random, &altcp_tls_entropy_rng->ctr_drbg);