Question

What is the meaning of RSA PRIVATE KEY and PUBLIC KEY that a x509 certificate contains?

UPD: @owlstead: I tried out phpseclib:

$text = "test"; 
$x509 = new File_X509();
$cert = $x509->loadX509(file_get_contents(CERT_PATH.'root.crt'));
$Crypt_RSA = $x509->getPublicKey();
extract($Crypt_RSA->createKey()); // got $publickey and $privatekey
$Crypt_RSA->loadKey($publickey);
$crypted_text = $Crypt_RSA->encrypt($text);
$Crypt_RSA->loadKey($privatekey);
$decrypted_text = $Crypt_RSA->decrypt($ciphertext);
Was it helpful?

Solution

createKey() creates a new key pair, i.e. a public and private key that do not belong to any certificate yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top