鍍金池/ 問答/PHP/ openssl_pkey_new 返回值為false

openssl_pkey_new 返回值為false

業(yè)務(wù)代碼

圖片描述

 function exportOpenSSLFile(){
            $config = array(
                "digest_alg"       => "sha512",
                "private_key_bits" => 4096,                     //字節(jié)數(shù)    512 1024  2048   4096 等
                "private_key_type" => OPENSSL_KEYTYPE_RSA,     //加密類型
            );
            $res = openssl_pkey_new($config);
            
            if($res == false) return false;
            openssl_pkey_export($res, $private_key);
            $public_key = openssl_pkey_get_details($res);
            $public_key = $public_key["key"];
            file_put_contents("/conf/cert_public.key",$public_key);
            file_put_contents("/conf/cert_private.pem",$private_key);
            openssl_free_key($res);
        }

        exportOpenSSLFile();

返回值

圖片描述

PHP配置

圖片描述

請問是不是還需要配置什么才可以???

回答
編輯回答
舊顏

openssl.cnf存在?

2018年1月29日 11:58