【发布时间】:2020-07-04 05:36:11
【问题描述】:
我目前正在将 CER 转换为 PEM。
我正在构建一个脚本,以使用 Openssl 将多个证书转换为不同的格式。我正在运行 PowerShell 7 和 Openssl 1.1.1e。当我运行我的脚本时,我得到了一些 Openssl 错误,但是它似乎仍然在转换证书,因为我之后仍然得到一个 .pem 文件。以下是错误:
Can't open Folder\Path for reading, Permission denied
17956:error:02001005:system library:fopen:Input/output error:..\crypto\bio\bss_file.c:69:fopen('C:\Users\localadmin\Desktop\PowerShell\Testing Environment\Folder\Path','r')
17956:error:2006D002:BIO routines:BIO_new_file:system lib:..\crypto\bio\bss_file.c:78:
unable to load certificate
Can't open Folder\Path for reading, Permission denied
19560:error:02001005:system library:fopen:Input/output error:..\crypto\bio\bss_file.c:69:fopen('C:\Users\localadmin\Desktop\PowerShell\Testing Environment\Folder\Path','r')
19560:error:2006D002:BIO routines:BIO_new_file:system lib:..\crypto\bio\bss_file.c:78:
unable to load certificate
unable to load certificate
17960:error:0909006C:PEM routines:get_name:no start line:..\crypto\pem\pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
unable to load certificate
16568:error:0909006C:PEM routines:get_name:no start line:..\crypto\pem\pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
unable to load certificate
21500:error:0909006C:PEM routines:get_name:no start line:..\crypto\pem\pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
unable to load certificate
15500:error:0909006C:PEM routines:get_name:no start line:..\crypto\pem\pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
我在使用 Openssl 制作 CSR 或私钥时没有任何错误。以下是我用于转换的代码:
if($CertType -eq "PEM") {
Get-ChildItem $ScriptPath\$Kit -Recurse -Force | ForEach-Object {
$OutFile = $_.FullName.ToString().Replace(".cer",".pem")
openssl x509 -in $_.FullName -outform PEM -out "$Outfile"}
}
【问题讨论】:
标签: powershell openssl certificate pem