From: Gabriel Goller <g.goller@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH v2] rest-server: check permissions on proxy.key and proxy.pem files
Date: Thu, 29 Aug 2024 15:07:12 +0200 [thread overview]
Message-ID: <20240829130712.34zozoysszkpwgj4@luna.proxmox.com> (raw)
In-Reply-To: <2ar5pj3cgxwqlyne4p5jfomwu6df3nxsskzul7ew3hcr676rtg@7dklhsjwdam4>
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
prev parent reply other threads:[~2024-08-29 13:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 12:10 Gabriel Goller
2024-08-29 12:21 ` Wolfgang Bumiller
2024-08-29 13:07 ` Gabriel Goller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240829130712.34zozoysszkpwgj4@luna.proxmox.com \
--to=g.goller@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=w.bumiller@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.