gpt4 book ai didi

PHP openssl_sign 停止执行所有脚本

转载 作者:可可西里 更新时间:2023-10-31 23:41:25 26 4
gpt4 key购买 nike

我在使用 openssl 时遇到问题。为了更好地查明问题,我做了两件事;我将代码缩减为单个测试页(我已从 php.net 中删除)。在问题仍然存在后,我将 tat 代码上传到服务器。服务器按预期工作,所以问题一定出在我的设置中!?我发现有人遇到了完全相同的问题,但他的代码不同,解决方案对我不起作用 (Service Applications and Google Analytics API V3: Error 101 (net::ERR_CONNECTION_RESET))。

这是代码:

<?php

$data = "Beeeeer is really good.. hic...";

// You can get a simple private/public key pair using:
// openssl genrsa 512 >private_key.txt
// openssl rsa -pubout <private_key.txt >public_key.txt

// IMPORTANT: The key pair below is provided for testing only.
// For security reasons you must get a new key pair
// for production use, obviously.

$private_key = <<<EOD
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBANDiE2+Xi/WnO+s120NiiJhNyIButVu6zxqlVzz0wy2j4kQVUC4Z
RZD80IY+4wIiX2YxKBZKGnd2TtPkcJ/ljkUCAwEAAQJAL151ZeMKHEU2c1qdRKS9
sTxCcc2pVwoAGVzRccNX16tfmCf8FjxuM3WmLdsPxYoHrwb1LFNxiNk1MXrxjH3R
6QIhAPB7edmcjH4bhMaJBztcbNE1VRCEi/bisAwiPPMq9/2nAiEA3lyc5+f6DEIJ
h1y6BWkdVULDSM+jpi1XiV/DevxuijMCIQCAEPGqHsF+4v7Jj+3HAgh9PU6otj2n
Y79nJtCYmvhoHwIgNDePaS4inApN7omp7WdXyhPZhBmulnGDYvEoGJN66d0CIHra
I2SvDkQ5CmrzkW5qPaE2oO7BSqAhRZxiYpZFb5CI
-----END RSA PRIVATE KEY-----
EOD;
$public_key = <<<EOD
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANDiE2+Xi/WnO+s120NiiJhNyIButVu6
zxqlVzz0wy2j4kQVUC4ZRZD80IY+4wIiX2YxKBZKGnd2TtPkcJ/ljkUCAwEAAQ==
-----END PUBLIC KEY-----
EOD;

$binary_signature = "";

// At least with PHP 5.2.2 / OpenSSL 0.9.8b (Fedora 7)
// there seems to be no need to call openssl_get_privatekey or similar.
// Just pass the key as defined above

openssl_sign($data, $binary_signature, $private_key, "sha1");

// Check signature
$ok = openssl_verify($data, $binary_signature, $public_key, "sha1");
echo "check #1: ";
if ($ok == 1) {
echo "signature ok (as it should be)\n";
} elseif ($ok == 0) {
echo "bad (there's something wrong)\n";
} else {
echo "ugly, error checking signature\n";
}

$ok = openssl_verify('tampered'.$data, $binary_signature, $public_key, "sha1");
echo "check #2: ";
if ($ok == 1) {
echo "ERROR: Data has been tampered, but signature is still valid! Argh!\n";
} elseif ($ok == 0) {
echo "bad signature (as it should be, since data has beent tampered)\n";
} else {
echo "ugly, error checking signature\n";
}

当我运行页面上方的代码时,需要一段时间才能加载,但随后会显示 net::ERR_CONNECTION_RESET:

net::ERR_CONNECTION_RESET

我启用了 openssl openssl

我正在使用 PHP 5.4.7 PHP 5.4.7

这些与我发现的另一种情况一样,除了我没有启动任何东西两次,而且这段代码在服务器上运行,它是 PHP 5.3.18。

我还能做什么?

最佳答案

velcrow 似乎是对的。我已经重新安装,现在一切正常。

关于PHP openssl_sign 停止执行所有脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17123029/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com