【发布时间】:2021-06-28 17:15:46
【问题描述】:
我已从 API 导出了一个基本 64 编码的证书,现在需要将其转换为 pkcs12 格式以上传到 Azure。下面的 PowerShell 脚本完美地完成了这项工作,但我无法将其转换为 OpenSSL。
$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)
我已经尝试了以下 2 个 OpenSSL 命令...
openssl base64 -d -a -in [base64.pfx] -out [converted.pfx]
openssl enc -base64 -d -in [base64.pfx] -out [converted.pfx]
...但是当我尝试使用证书时,它们都返回相同的错误:
34359836736:error:0D07207B:asn1 编码例程:ASN1_get_object:header too long:crypto/asn1/asn1_lib.c:101: pkcs12中的错误
任何有关此转换的帮助将不胜感激。提前致谢!
【问题讨论】:
标签: azure powershell openssl ssl-certificate