使用函数openssl_get_cipher_methods() ,打印的数组里不包含sm4
服务器上查看openssl版本是1.1.1w,官网消息1.1.1+的算法里面是支持sm4算法的
使用命令行:
openssl enc -ciphers | grep sm4
由于Openssl是后期升级的,PHP是集成环境中的,然后查看PHP编译的openssl版本
php -i | grep -i openssl
Configure Command => './configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-config-file-scan-dir=/usr/local/php/conf.d' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv=/usr/local' '--with-freetype=/usr/local/freetype' '--with-jpeg' '--with-zlib' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--enable-intl' '--enable-ftp' '--enable-gd' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-zip' '--enable-soap' '--with-gettext' '--enable-opcache' '--with-xsl' '--with-pear' '--with-webp' 'PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/rh/devtoolset-9/root/usr/lib64/pkgconfig'
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.2k-fips 26 Jan 2017
OpenSSL Header Version => OpenSSL 1.0.2k 26 Jan 2017
Openssl default config => /etc/pki/tls/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
Native OpenSSL support => enabled
编译的时候指定openssl地址,同时还有两个前提条件
#编译时加上
--with-openssl=/usr/local/openssl-1.1.1w
openssl version -a
然后,编译PHP前,先执行:
export PKG_CONFIG_PATH=/usr/local/openssl-1.1.1w/lib/pkgconfig:$PKG_CONFIG_PATH
ldconfig -v /usr/local/openssl-1.1.1w/lib
php -i | grep -i openssl
# 预期输出OpenSSL Library Version为1.1.1w