使用openssl函数的PHP会导致网页无法加载

使用openssl函数的PHP会导致网页无法加载,php,encryption,openssl,private-key,Php,Encryption,Openssl,Private Key,所以我第一次使用加密和解密,遇到了一些问题。要获取私钥和公钥,我有以下代码: //get public key $client_cert = openssl_x509_read(file_get_contents("path\to\certificate")); $pub_key = openssl_pkey_get_public($client_cert); //get private key $pk = file_get_contents("path\to\pk.pem"); $priva

所以我第一次使用加密和解密,遇到了一些问题。要获取私钥和公钥,我有以下代码:

//get public key
$client_cert = openssl_x509_read(file_get_contents("path\to\certificate"));
$pub_key = openssl_pkey_get_public($client_cert);

//get private key
$pk = file_get_contents("path\to\pk.pem");
$private_key = openssl_pkey_get_private($pk);
如果我在$pub_key或$private_key上运行var转储,我会发现它们都是OpenSSL key类型的资源。但是,如果我尝试运行openssl_pkey_get_获取其中任何一个的详细信息,该网页将死亡,并且我会收到一条消息说该网页不可用。如果我尝试运行此行,也会发生这种情况:

openssl_private_encrypt($server_challenge, $encrypted_server_challenge, $private_key);
我检查了apache和php日志,但它们都没有显示任何内容。任何帮助都将不胜感激

编辑:这是完整的代码块

//get public key
$client_cert = openssl_x509_read(file_get_contents("C:\Users\Brandon\Desktop\Work\ClientCertification.cer"));
$pub_key = openssl_pkey_get_public($client_cert);

//get private key
$pk = file_get_contents("C:\Users\Brandon\Desktop\Work\pk.pem");
$private_key = openssl_pkey_get_private($pk);

$client = new SoapClient("https://ws5.responsys.net/webservices/wsdl/ResponsysWS_Level1.wsdl");
$response = $client->authenticateServer($this->loginParameters);

//encrypt server challenge with private key
$server_challenge = implode($response->result->serverChallenge);

openssl_private_encrypt($server_challenge, $encrypted_server_challenge, $private_key);

哪个网页死了?向我们展示您正在执行的代码和请求。启用E_所有错误级别和显示错误。这只是我正在编写的一个简单脚本。我只是想通过获取字符串并使用私钥对其进行加密来学习如何使用加密。我现在唯一的请求就是调用上面提到的openssl\u private\u encrypt。请不要尴尬或害羞,向我们展示代码。创建它的原因并不重要。我将其编辑到原始帖子中,我之前只遗漏了三行额外的代码。我绕过它,发现另一篇帖子中有人有同样的问题。作为临时修复,因为我目前不需要SSL,所以我将libeay32.dll和ssleay32.dll从xampp\php复制到xampp\apache\bin。显然,这只是xampp最新版本的一个问题。谢谢你的帮助!