public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] cert: fix invalid CSR version
@ 2023-03-31 16:12 Mira Limbeck
  2023-04-03 12:13 ` Mira Limbeck
  2023-04-20 12:32 ` [pve-devel] applied: " Fabian Grünbichler
  0 siblings, 2 replies; 3+ messages in thread
From: Mira Limbeck @ 2023-03-31 16:12 UTC (permalink / raw)
  To: pve-devel

According to rfc2986 the only valid version is 0. No newer rfc changed
that.
See section 4.1:
https://www.rfc-editor.org/rfc/rfc2986#section-4.1

Manually verifying the CSR with openssl results in the following error:
```
$ openssl req -in bad.csr -text -noout
Certificate Request:
    Data:
        Version: Unknown (2)
```

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
I wasn't able to create a test setup where I could test this yet, will
try again on monday.

Stoiko tested it on his setup with Let's Encrypt Staging and it worked
fine. Although he didn't extract the CSR to verify it.

A customer reported the issue in the enterprise support portal and
provided the fix as well.

 src/PVE/Certificate.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Certificate.pm b/src/PVE/Certificate.pm
index 4ce7364..f67f6cd 100644
--- a/src/PVE/Certificate.pm
+++ b/src/PVE/Certificate.pm
@@ -430,7 +430,7 @@ sub generate_csr {
 
     $cleanup->("Failed to set public key\n") if !Net::SSLeay::X509_REQ_set_pubkey($req, $pk);
 
-    $cleanup->("Failed to set CSR version\n") if !Net::SSLeay::X509_REQ_set_version($req, 2);
+    $cleanup->("Failed to set CSR version\n") if !Net::SSLeay::X509_REQ_set_version($req, 0);
 
     $cleanup->("Failed to sign CSR\n") if !Net::SSLeay::X509_REQ_sign($req, $pk, $md);
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH common] cert: fix invalid CSR version
  2023-03-31 16:12 [pve-devel] [PATCH common] cert: fix invalid CSR version Mira Limbeck
@ 2023-04-03 12:13 ` Mira Limbeck
  2023-04-20 12:32 ` [pve-devel] applied: " Fabian Grünbichler
  1 sibling, 0 replies; 3+ messages in thread
From: Mira Limbeck @ 2023-04-03 12:13 UTC (permalink / raw)
  To: pve-devel

Looks like a python-cryptography maintainer opened a pull request on 
Github with the exact same change: 
https://github.com/proxmox/pve-common/pull/8




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH common] cert: fix invalid CSR version
  2023-03-31 16:12 [pve-devel] [PATCH common] cert: fix invalid CSR version Mira Limbeck
  2023-04-03 12:13 ` Mira Limbeck
@ 2023-04-20 12:32 ` Fabian Grünbichler
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2023-04-20 12:32 UTC (permalink / raw)
  To: Proxmox VE development discussion

thanks! (and sorry for the delay)

On March 31, 2023 6:12 pm, Mira Limbeck wrote:
> According to rfc2986 the only valid version is 0. No newer rfc changed
> that.
> See section 4.1:
> https://www.rfc-editor.org/rfc/rfc2986#section-4.1
> 
> Manually verifying the CSR with openssl results in the following error:
> ```
> $ openssl req -in bad.csr -text -noout
> Certificate Request:
>     Data:
>         Version: Unknown (2)
> ```
> 
> Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
> ---
> I wasn't able to create a test setup where I could test this yet, will
> try again on monday.
> 
> Stoiko tested it on his setup with Let's Encrypt Staging and it worked
> fine. Although he didn't extract the CSR to verify it.
> 
> A customer reported the issue in the enterprise support portal and
> provided the fix as well.
> 
>  src/PVE/Certificate.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/PVE/Certificate.pm b/src/PVE/Certificate.pm
> index 4ce7364..f67f6cd 100644
> --- a/src/PVE/Certificate.pm
> +++ b/src/PVE/Certificate.pm
> @@ -430,7 +430,7 @@ sub generate_csr {
>  
>      $cleanup->("Failed to set public key\n") if !Net::SSLeay::X509_REQ_set_pubkey($req, $pk);
>  
> -    $cleanup->("Failed to set CSR version\n") if !Net::SSLeay::X509_REQ_set_version($req, 2);
> +    $cleanup->("Failed to set CSR version\n") if !Net::SSLeay::X509_REQ_set_version($req, 0);
>  
>      $cleanup->("Failed to sign CSR\n") if !Net::SSLeay::X509_REQ_sign($req, $pk, $md);
>  
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-20 12:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31 16:12 [pve-devel] [PATCH common] cert: fix invalid CSR version Mira Limbeck
2023-04-03 12:13 ` Mira Limbeck
2023-04-20 12:32 ` [pve-devel] applied: " Fabian Grünbichler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal