openssl_pkey_new 返回值为false

业务代码

图片描述

 function exportOpenSSLFile(){
            $config = array(
                "digest_alg"       => "sha512",
                "private_key_bits" => 4096,                     //字节数    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配置

图片描述

请问是不是还需要配置什么才可以啊?

阅读 4.8k
1 个回答

openssl.cnf存在?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题