From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B29961FF163 for ; Thu, 29 Aug 2024 15:07:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 02CBF1C675; Thu, 29 Aug 2024 15:07:46 +0200 (CEST) Date: Thu, 29 Aug 2024 15:07:12 +0200 From: Gabriel Goller To: Wolfgang Bumiller Message-ID: <20240829130712.34zozoysszkpwgj4@luna.proxmox.com> References: <20240829121047.243804-1-g.goller@proxmox.com> <2ar5pj3cgxwqlyne4p5jfomwu6df3nxsskzul7ew3hcr676rtg@7dklhsjwdam4> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2ar5pj3cgxwqlyne4p5jfomwu6df3nxsskzul7ew3hcr676rtg@7dklhsjwdam4> User-Agent: NeoMutt/20220429 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.041 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pbs-devel] [PATCH v2] rest-server: check permissions on proxy.key and proxy.pem files X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Cc: pbs-devel@lists.proxmox.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" On 29.08.2024 14:21, Wolfgang Bumiller wrote: >On Thu, Aug 29, 2024 at 02:10:47PM GMT, Gabriel Goller wrote: >> [skip] >> @@ -88,9 +90,17 @@ impl TlsAcceptorBuilder { >> .context("failed to set tls acceptor certificate")?; >> } >> Some(Tls::FilesPem(key, cert)) => { >> + let key_content = >> + file_read_string(key).context("Failed to read from private key file")?; > >Why not `std::fs::read()`? openssl expects bytes below, the utf-8 check >is unnecessary. >(just include the path via `.with_context(|| format!(...))`) Good point! >> acceptor >> - .set_private_key_file(key, SslFiletype::PEM) >> + .set_private_key(PKey::private_key_from_pem(key_content.as_bytes())?.as_ref()) >> .context("failed to set tls acceptor private key file")?; >> + >> + { >> + // Check the permissions by opening the file >> + let _cert_fd = std::fs::File::open(&cert) >> + .context(format!("Failed to open certificate at {:?}", cert))?; > >use `.with_context` to avoid formatting the string when no error >happens. Done as well, thanks for the review! Submitted a v3. _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel