Powershell 读取openssl.cnf文件时出现权限被拒绝错误
我正在尝试通过powershell生成SSL证书,并使用openssl进行验证。 下面是我的代码:Powershell 读取openssl.cnf文件时出现权限被拒绝错误,powershell,openssl,csr,Powershell,Openssl,Csr,我正在尝试通过powershell生成SSL证书,并使用openssl进行验证。 下面是我的代码: Function new-csr { [CmdletBinding()] Param( $country, #2 please enter char country code $state, #state $locality, #city $org, # organization name $ou, # orhanization unit name $cn, # common nam
Function new-csr {
[CmdletBinding()]
Param(
$country, #2 please enter char country code
$state, #state
$locality, #city
$org, # organization name
$ou, # orhanization unit name
$cn, # common name hostname
$email, # contact email
$randPath, # path for file
$privateKeyPath, # path to private key
$csrPath # path to certificate signin request (output)
)
# if private key has not been created , create one
if(-not (Test-Path $privateKeyPath)){
openssl genrsa -out $privateKeyPath 2048
}
if(-not(Test-Path $randPath)){
openssl rand -out $randPath
}
$subject = "`"/C=$country/ST=$state/L=$locality/O=$org/OU=$ou/CN=$cn`""
openssl req -new -key $privateKeyPath -rand $randPath -subj $subject -out $csrPath
}
在管理员权限下尝试在PowerShell中执行时。我的权限被拒绝。
我猜这可能是因为.cnf文件在程序文件下。那么,我是否应该尝试卸载PowerShell并再次在Program Files文件夹外安装
无法打开C:\Program Files\OpenSSL-Win64\bin\cnf进行读取,权限被拒绝
9604:错误:020001005:系统库:fopen:输入/输出错误:crypto\bio\bss_file.c:69:fopen('c:\Program Files\OpenSSL-Win64\bin\cnf','rb')
9604:错误:2006D002:BIO例程:BIO_新文件:系统库:加密\BIO\bss_文件。c:78:
9604:错误:0E078002:配置文件例程:def_加载:系统库:crypto\conf\conf_def.c:170:
9604:错误:020001005:系统库:fopen:输入/输出错误:crypto\bio\bss_file.c:69:fopen('c:\Program Files\OpenSSL-Win64\bin\cnf','r')
9604:错误:2006D002:BIO例程:BIO_新文件:系统库:加密\BIO\bss_文件。c:78:
对于OpenSSL配置,我添加了环境变量和用户变量:
环境变量:路径为
C:\Program Files\OpenSSL-Win64\bin用户变量作为 OPENSSL_CONF=C:\Program Files\OPENSSL-Win64\bin\cnf
我发现了问题。问题在于您是否使用公司笔记本电脑或VPN。很可能您将面临访问ProgramFiles文件夹中的文件的权限问题 我卸载了OpenSSL并在ProgramFiles文件夹外重新安装了它。确保它安装在程序文件之外
这对我有用。我可以创建CSR。您的配置文件本身是否
…OpenSSL-Win64\bin\cnf
,看起来像一个目录?文件通常是..\openssl.cnf
。