powershell - Powershell:使用循环将证书转换为 pfx
问题描述
我正在尝试使用循环将一堆证书转换为 pfx 格式,因为有很多。我遇到的问题是关于私钥的。我不确定如何使用正确的证书循环正确的私钥。下面是我的循环
Get-ChildItem -Path $CertPath\SCP -Recurse -Include "*cer", "*.key" |
ForEach-Object {
$OutFile = $_.FullName.ToString().Replace(".cer",".pfx")
$Password = Read-host "enter the password" -AsSecureString
openssl pkcs12 -export -in $CertPath\Folder -inkey $PrivateKey -out $Outfile -password $Password}
解决方案
如果Basename
key 和 cert 文件匹配,只需进行另一个替换:
$key = $_.FullName.ToString().Replace('.cer','.key')
推荐阅读
- react-native - React Native Router Flux 道具不通过动作
- javascript - Material ui Textfield Hinttext overlap with with text when text is set with setState in react
- pyomo - 在 Pyomo 中使用 GLPK 优化后,如何检索使用的时间和相对 MIP 间隙?
- forms - 在 Cakephp 3.6 中,如何获取图像的大小和类型以通过表单发送?
- python - 如何在 Keras 中仅获取序列模型的最后输出?
- reactjs - HighChart 未在 reactjs 中显示“表格”
- php - 如何在 Laravel 中使用正确的 Sweet Alert 和重定向?
- groovy - 使用 PostProcessor 将响应保存到 JMeter 中的文件
- tensorflow - 使用带有 tf.estimator 的 keras 模型时如何进入 TensorBoard 精度图?
- rest - 删除文档失败时,MarkLogic 开箱即用的 rest api 会返回什么?