I think from the message error, the string might not be properly Base64 encoded, it might contain extra characters like spaces, newlines or other.. which are not part of the Base64 encoding.
Check with Powershell :
$base64String = "your_base64_string_here"
$bytes = [System.Convert]::FromBase64String($base64String)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($bytes)
You can trim the string and remove any unnecessary characters:
string base64String = "your_base64_string_here".Trim();