]> git.proxmox.com Git - proxmox-acme.git/commitdiff
eba: support decoding MAC key provided in base64url format master
authorYU Jincheng <shana@zju.edu.cn>
Thu, 25 Jan 2024 08:28:01 +0000 (16:28 +0800)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 12 Feb 2024 08:51:51 +0000 (09:51 +0100)
According to RFC 8555:

> The MAC key SHOULD be provided in base64url-encoded form...

However, currently we are only decoding the MAC key as base64.
This patch chooses the correct function to decode the user provided
MAC key. This can fix authentication error when a user uses command
`pvenode acme account register` and paste the EBA MAC key as prompted.

Signed-off-by: YU Jincheng <shana@zju.edu.cn>
Tested-by: Folke Gleumes <f.gleumes@proxmox.com>
 [ TL: fix typo in message, reword subject ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/ACME.pm

index bf5410d551ecb1a305d5a20ffc459ecd94499778..65094c20d1707f99e2e47e8576885db89f44aee4 100644 (file)
@@ -7,7 +7,7 @@ use POSIX;
 
 use Data::Dumper;
 use Date::Parse;
-use MIME::Base64 qw(encode_base64url decode_base64);
+use MIME::Base64 qw(encode_base64url decode_base64 decode_base64url);
 use File::Path qw(make_path);
 use JSON;
 use Digest::SHA qw(sha256 sha256_hex hmac_sha256);
@@ -365,7 +365,12 @@ sub new_account {
     my %payload = ( contact => $info{contact} );
 
     if (defined($info{eab})) {
-       my $eab_hmac_key = decode_base64($info{eab}->{hmac_key});
+       my $eab_hmac_key;
+       if ($info{eab}->{hmac_key} =~ m/[+\/]/) {
+           $eab_hmac_key = decode_base64($info{eab}->{hmac_key});
+       } else {
+           $eab_hmac_key = decode_base64url($info{eab}->{hmac_key});
+       }
        $payload{externalAccountBinding} = external_account_binding_jws(
            $info{eab}->{kid},
            $eab_hmac_key,