openssl_pkey_export和“无法从参数1获取密钥" [英] openssl_pkey_export and "cannot get key from parameter 1"

查看:533
本文介绍了openssl_pkey_export和“无法从参数1获取密钥"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的php项目中使用openssl,因此我使用openssl创建了一个测试php页面.但是,我不断收到这些错误,我不确定为什么. openssl已启用.

I need to use openssl within my php project, so I created a test php page using openssl. However, I keep getting these errors and I am not sure why. openssl is enabled.

警告:openssl_pkey_export()[function.openssl-pkey-export]:无法从第18行的C:\ wamp \ www \ opensslsample \ index.php中的参数1获取密钥

Warning: openssl_pkey_export() [function.openssl-pkey-export]: cannot get key from parameter 1 in C:\wamp\www\opensslsample\index.php on line 18

警告:openssl_pkey_get_details()期望参数1为资源,在第21行的C:\ wamp \ www \ opensslsample \ index.php中给出布尔值

Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in C:\wamp\www\opensslsample\index.php on line 21

<?php
 //echo phpinfo();

   $privateKey = openssl_pkey_new(array(
'private_key_bits' => 1024,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));

openssl_pkey_export($privateKey, $privkey,"123");

$pubkey=openssl_pkey_get_details($privateKey);
$pubkey=$pubkey["key"];
?>

推荐答案

如果您在Windows上,这可能会有所帮助:

This may help if you are on windows:

  1. 点击开始"按钮
  2. 单击控制面板
  3. 单击系统和安全性
  4. 点击SYSTEM
  5. 单击高级系统设置
  6. 单击环境变量
  7. 在系统变量"下,单击新建"
  8. 输入变量名" OPENSSL_CONF
  9. 输入变量值".我是-C:\ wamp \ bin \ apache \ Apache2.2.17 \ conf \ openssl.cnf
  10. 单击确定"并关闭所有窗口,然后重新启动计算机.
  1. Click on the START button
  2. Click on CONTROL PANEL
  3. Click on SYSTEM AND SECURITY
  4. Click on SYSTEM
  5. Click on ADVANCED SYSTEM SETTINGS
  6. Click on ENVIRONMENT VARIABLES
  7. Under "System Variables" click on "NEW"
  8. Enter the "Variable name" OPENSSL_CONF
  9. Enter the "Variable value". My is - C:\wamp\bin\apache\Apache2.2.17\conf\openssl.cnf
  10. Click "OK" and close all the windows and RESTART your computer.

OPENSSL应该可以正常工作.

The OPENSSL should be correctly working.

这篇关于openssl_pkey_export和“无法从参数1获取密钥"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆