ovpnmain.cgi: Fix OTP secret handling

Convert stored hex OTP secret to binary prior to converting to base32.
This commit is contained in:
Timo Eissler
2022-06-07 11:20:56 +02:00
committed by Michael Tremer
parent 16d4a5c264
commit 10b32d3895

View File

@@ -2655,7 +2655,7 @@ else
darkcolor => Imager::Color->new(0, 0, 0),
);
my $cn = $confighash{$cgiparams{'KEY'}}[2];
my $secret = encode_base32($confighash{$cgiparams{'KEY'}}[44]);
my $secret = encode_base32(pack('H*', $confighash{$cgiparams{'KEY'}}[44]));
my $issuer = "$mainsettings{'HOSTNAME'}.$mainsettings{'DOMAINNAME'}";
my $qrcodeimg = $qrcode->plot("otpauth://totp/$cn?secret=$secret&issuer=$issuer");
my $qrcodeimgdata;