My PHP script is generating only partial keys, they are about 50% of what they should be and are missing the closing headers, here is how I generate the keys:
private function GetKeyPair(&$private_key, &$public_key){
//write your configurations :D
$configargs = array(
"config" => "C:/xampp/php/extras/openssl/openssl.cnf",
'private_key_bits'=> 2048,
'digest_alg' => 'sha256',
//'default_md' => "sha256",
);
// Create the keypair
$res=openssl_pkey_new($configargs);
// Get private key
openssl_pkey_export($res, $private_key,NULL,$configargs);
// Get public key details
$private_key_details = openssl_pkey_get_details($res);
$public_key=$private_key_details["key"];
return true;
}
The $private_key I obtain looks like this:
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC5Q2uupK5kjw9G
7mFFq8AxbTCYc91ZsV//oDqKE7+xOMkfZIXIAROC3HZm6DO2lMDkNSLhWIOyHvDS
+rrLK9DM4lQafmUmiVRkdaDCEcKzd6gKQuatutmVRuqpFTLO6HAN15KOEOi48R72
KeNn5h2wML/ut3Q7W6T1/jNJPViBVMDD
While the $public_key is:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuUNrrqSuZI8PRu5hRavA
MW0wmHPdWbFf/6A6ihO/sTjJH2SFyAETgtx2ZugztpTA5DUi4ViDsh7w0vq6yyvQ
zOJUGn5lJolUZHWgwhHCs3eoCkLmrbrZlUbqqRUyzuhwDdeSjhDouPEe9injZ+Yd
sDC/7rd0O1uk9f4zST1YgVTAw/r9sbijP
I could not find anything in my config file pointing that the keys will be truncated, and these values are before being snet ot the database, if I inspect the variables they are also truncated.