我正在尝试编写 OpenSSLec
命令脚本。该脚本用于验证另一个库生成的密钥集合。该脚本在问题后面显示如下。
以下操作在终端进行:
openssl ec -in ec-enc-priv-xxx.pem -passin pass:test -text -noout
以下操作在终端进行:
openssl ec -in ec-enc-priv-xxx.pem -passin pass:test -text -noout >/dev/null
但是,当我编写最后一个脚本时,系统提示我输入密码:
$ ./pem-verify.sh
read RSA key
read RSA key
read RSA key
read DSA key
read DSA key
read DSA key
read EC key
read EC key
Enter PEM pass phrase:
脚本中的 RSA 和 DSA 密钥均适用相同的代码。问题仅出在加密的 EC 私钥上。
有什么想法可以解决这个问题吗?
#! /bin/sh
# Script to verify the test keys written by pem-test.cpp
#################
# RSA keys
# The RSA command returns 0 on success
openssl rsa -in rsa-pub-xxx.pem -pubin -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read RSA public key"
fi
openssl rsa -in rsa-priv-xxx.pem -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read RSA private key"
fi
openssl rsa -in rsa-enc-priv-xxx.pem -passin pass:test -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read encrypted RSA private key"
fi
#################
# DSA keys
# The DSA command is broken. It returns 1 when using '-noout' option
# instead of 0. A patch was submitted to RT.
openssl dsa -in dsa-pub-xxx.pem -pubin -text -noout >/dev/null
openssl dsa -in dsa-priv-xxx.pem -text -noout >/dev/null
openssl dsa -in dsa-enc-priv-xxx.pem -passin pass:test -text -noout >/dev/null
#################
# EC keys
# The EC command returns 0 on success
openssl ec -in ec-pub-xxx.pem -pubin -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read EC public key"
fi
openssl ec -in ec-priv-xxx.pem -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read EC private key"
fi
openssl ec -in ec-enc-priv-xxx.pem -passin pass:test -text -noout >/dev/null
RET=$?
if [ $RET -ne 0 ];then
echo "Failed to read encrypted EC private key"
fi
答案1
我鄙视这类答案,但自从重启 MacBook Pro 以来,我无法重现该问题。因此,在这种情况下,答案似乎是重启。唉……
由于该问题无法重现,因此关闭该问题。