powershell - 读取 openssl.cnf 文件时出现权限被拒绝错误
问题描述
我正在尝试通过 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 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 文件位于 Program Files 下。那么我应该尝试卸载 PowerShell 并这次在 Program Files 文件夹之外再次安装吗?
无法打开 C:\Program Files\OpenSSL-Win64\bin\cnf 进行读取,权限被拒绝 9604:error:02001005:system library:fopen:Input/output error:crypto\bio\bss_file.c:69:fopen( 'C:\Program Files\OpenSSL-Win64\bin\cnf','rb') 9604:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:78: 9604:error:0E078002:配置文件例程:def_load:system lib:crypto\conf\conf_def.c:170: 9604:error:02001005:system library:fopen:Input/output error:crypto\bio\bss_file.c:69:fopen('C: \Program Files\OpenSSL-Win64\bin\cnf','r') 9604:error:2006D002:BIOroutines:BIO_new_file:system lib:crypto\bio\bss_file.c:78:
对于 OpenSSL 配置,我添加了环境变量和用户变量:
EnvironmentVariable:路径为 C:\Program Files\OpenSSL-Win64\bin
UserVariable 为 OPENSSL_CONF= C:\Program Files\OpenSSL-Win64\bin\cnf
解决方案
我发现了这个问题。问题是您使用的是公司笔记本电脑还是 VPN。很可能您将面临访问 Program Files 文件夹中文件的权限问题。
我卸载了 OpenSSL 并将其重新安装在 Program Files 文件夹之外。确保它安装在 Program Files 之外。
这对我有用。我能够创建企业社会责任。
推荐阅读
- xml - 在 Delphi 中创建 OpenXML app.xml 已添加属性
- c++ - 通知 c 或 c++ 编译器循环长度是 8 的倍数
- java - 在 Java/Spring 启动中,如何每次使用 Azure Key Vault 中的最新机密开发 Azure Change Feed 流程
- javascript - Manually clicking a link in Android Google Chrome behaves differently than clicking it through code
- python - 弹跳锯不会与玩家发生碰撞
- python - 当并非所有目录都包含 python 文件时,如何将 sphinx 与嵌套目录一起使用
- vba - Word 365 vba - 如何复制域代码公式?
- python - 如何使用 python 访问移动摄像头或网络摄像头,但不使用 opencv?
- python - 为什么我的 python discord bot 在 tts 中发送消息?(在 repl.it 上)
- android - 如何使用 Xamarin.forms 访问 Android 中的使用设置?