title: Convert Base-64 pfx to Usable pkcs#12
body: <p>I've exported a base 64-encoded certificate from an API and now need to convert it to a pkcs12 format to be uploaded to Azure. The below PowerShell script does this job perfectly, but I'm having trouble converting this to OpenSSL.</p>
  <pre><code>$base64value = Get-Content -Path $base64FilePath
  $byteArray = [System.Convert]::FromBase64String($base64value)
  $cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($byteArray, $certPw, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
  # Export the certificate as a PFX file
  $bytesPfx = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $certPw)
  [System.IO.File]::WriteAllBytes($pkcs12FilePath, $bytesPfx)
  </code></pre>
  <p>I've tried the following 2 OpenSSL commands...</p>
  <pre><code>openssl base64 -d -a -in [base64.pfx] -out [converted.pfx]
  </code></pre>
  <pre><code>openssl enc -base64 -d -in [base64.pfx] -out [converted.pfx]
  </code></pre>
  <p>...but these both return the same error when I attempt to use the certificate:</p>
  <blockquote>
  <p>34359836736:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:crypto/asn1/asn1_lib.c:101:
  error in pkcs12</p>
  </blockquote>
  <p>Any help with this conversion would be greatly appreciated. Thanks in advance!</p>