我想在PHP中使用shell_exec方法执行openssl命令。
命令成功,但是当我使用shell_exec运行它时,我得到以下错误:
从错误中看来,这个选项已经过时了,但我找不到替代选项。
谁有什么建议?unknown option 2
usage: s_client args
-host host - use -connect instead
-port port - use -connect instead
-connect host:port - who to connect to (default is localhost:4433)
-verify_hostname host - check peer certificate matches "host"
-verify_email email - check peer certificate matches "email"
-verify_ip ipaddr - check peer certificate matches "ipaddr"
-verify arg - turn on peer certificate verification
-verify_return_error - return verification errors
-cert arg - certificate file to use, PEM format assumed
-certform arg - certificate format (PEM or DER) PEM default
-key arg - Private key file to use, in cert file if
not specified but cert file is.
-keyform arg - key format (PEM or DER) PEM default
-pass arg - private key file pass phrase source
-CApath arg - PEM format directory of CA's
-CAfile arg - PEM format file of CA's
-trusted_first - Use trusted CA's first when building the trust chain
# OpenSSL Version
openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
$response = shell_exec('openssl s_client -servername {$domain_name} -connect {$domain_name}:443 2 >/dev/null | openssl x509 -noout -enddate | grep notAfter | sed -e s#notAfter=##');
如果2 >/dev/null
要将错误重定向为null,则应该删除空格2>/dev/null
,否则2将被视为命令参数