小编Mic*_*ash的帖子

错误消息 - openssl:找不到命令

我正在编写一个简单的脚本来检查网站的证书是否有效。但是,当我尝试在终端中运行代码时,我收到一条错误消息,指出openssl找不到该命令。这是代码:

if true | openssl s_client -connect www.google.com:443 2>/dev/null | \
  openssl x509 -noout -checkend 0; then
  echo "Certificate is not expired"
else
  echo "Certificate is expired"
fi
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此代码时,我收到以下输出:

if true | openssl s_client -connect www.google.com:443 2>/dev/null | \
  openssl x509 -noout -checkend 0; then
  echo "Certificate is not expired"
else
  echo "Certificate is expired"
fi
Run Code Online (Sandbox Code Playgroud)

代码运行,但它不能识别openssl为有效命令,因此它跳过提到这一点的代码行,并默认输出“证书已过期”。

使用时sudo apt-get install openssl我收到此消息:

./check-certificates.sh: line 6:  openssl: command not found
Certificate is expired
Run Code Online (Sandbox Code Playgroud)

所以看起来openssl已经成功安装了。我不知道如何解决这个问题 …

scripting bash openssl command-not-found

3
推荐指数
1
解决办法
9056
查看次数

标签 统计

bash ×1

command-not-found ×1

openssl ×1

scripting ×1