openssl_public_encrypt在大型输入上返回空输出

时间:2018-08-22 14:43:53

标签: php encryption openssl

我正在尝试使用另一个公共证书对CSR进行加密。如果我仅使用一小部分CSR并进行了加密,则可以正常工作。但是随着我使用越来越大的csr,它将返回和空加密?

$csr = 'MIIC6jCCAdICAQAwgaQxKjAoBgNVBAMMITAwMTA0NDQ1MDgwMDFAMTU1Mi0yMTE4LTU0NTQtNTA2MDETMBEGA1UECwwKRHluYWNjb3VudDETMBEGA1UECgwKRHluYWNjb3VudDELMAkGA1UEBwwCREsxCzAJBgNVBAgMAkRLMQswCQYDVQQGEwJESzElMCMGCSqGSIb3DQEJARYWc3VwcG9ydEBkeW5hY2NvdW50LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMYi8LrXlsyABKJt7tr/ik3ruNovreQMPmaEoeHG/URIHKlQohz9uiY6d+/IpwIA5UHJvsw1BEFEe7SLEXnVke0VlNupfE3TP31JW10EIn+gh9qC1suSVBYz0ieg6YkTCBRkYnAHOEax2LL3/TyiPJR4oSG5Lkwh+XfQkjgIQakWdAYVmf83otwdjwq8cMZpqs9aIDKzSfjz1hG2eQYy/N3slolaBLJ+GC/koKdXMOdFSc6M8t/OJMc6rxmyJd7NwtxsVnW4NCUvOa3DyC+ekKapc7KMXfKoOHe5sqaTA1RKnHISaFzDZ+uGFY8kPne+Ai3RG4x9gdSEBpez3hxwj5ECAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQAb+NZTgcYbyjpXF+drhbulJzDZHBe0iqzHfD/qFiu0vEaZPbm7PUZQDMLWq5TTTdJCrrvOIPoQL7Yi4oAR234R/d+1hVcowWpJYtLHL2bH60sOssu3WNDxnlwRE0VsSA8bMVR4PXqYxxLD7t5FabznngcTBvVXxfvgEAZKtDpdT44ANLjTeXWbpTcnZWiDluCVGx925WoqCzFqTrJ1LvK2vndhvfJOuHOnLIunFXbmSdDW1stdDg6CboViWglwSVN8BwjaWeL8l/PCemhzIh9DIhjzL3F+xdF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O8f6tPt8Uw8MtokwDQYJKoZIhvcN'."\n"
.'AQELBQADggIBAFxf4QCazXaZTqT9E24JJSBTOiq4Wa8431UfCnKpMfrN8ES9+S2h'."\n"
.'JXLcqfPVyUj/flYuJqECJSVjE5InwDmzAOmaMkUcdUOH9vOJiRwIm8Iu83RN9mKc'."\n"
.'bX2XyeeU2en24dP9EVqCRYDEcT8v7dGS1sRLrt8r07VJABq6C1LeuBoMJSNF7CE+'."\n"
.'hTBlPxccL2zLZjsvuPkm7w590SJpo3uODo4wNHRF/fO+yb4QIuUEjI81sIWoyqla'."\n"
.'M9NoZ+jZ8jNsUqtMmWiPR9pscBidC5ylb6/xfIrvY9P4u1GADM7mxT1D0x56Y7md'."\n"
.'1YlEvY3EOMjk1zlkLlPrRhqdfvk6YnCX+WRaFDPXau11uYfxw2UjqV4UoSQxWoiW'."\n"
.'efzJIHYKPJjQkyPutNvstTsJ53D/TmA2gLFu475lk4Uy/eYCvmdbUncIXTuATZge'."\n"
.'Zq0IOfP15J/FFa6nq25gjTc/7AIXH3IaFwvMDzLln7sNl5DMGQTGeXPPUUwJgtU8'."\n"
.'L4Mk9QLqUG8GgO3WJixy5rv/pU0AqLzZrqsnGOJ+zmUPMums2bNSahYuN/zhGT2R'."\n"
.'MGLUfpIrmFxKP9x6TxfXRSPVFbTXF8TrQk9LkOPXKf0JxuNT9MjmEmnvWfWEhUBu'."\n"
.'hfu507iTkyjx1yRbHRjz2OhSBY3c++IpvOvhef3NbM+bOJirR6yD3VR6'."\n"
.'-----END CERTIFICATE-----'."\n";

// smaller piece of csr
$csr = 'MIIC6jCCAdICAQAw';

$public_cert = openssl_pkey_get_public($public);
openssl_public_encrypt($csr, $enc_data, $public_cert);
openssl_free_key($public_cert);
echo "enc_data: $enc_data\n";

0 个答案:

没有答案