Problem with phpseclib and PDO

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

Problem with phpseclib and PDO

Postby Registration » Wed Nov 06, 2013 6:17 pm

Hi, i'm trying to pass a public_key recovered trough a PDO query to phpseclib, but i get the following error:
Code: Select all
Fatal error: Uncaught exception 'PDOException' with message 'You cannot serialize or unserialize PDO instances'

The code i actually use is:
Code: Select all
   $stmt = $pdo->prepare("SELECT public_key FROM users WHERE username = ?");
   $row = $stmt->fetch();
      $public_key = $row['public_key'];
      $rsa = new Crypt_RSA();
      $ciphertext = base64_encode($rsa->encrypt($details));

Posts: 1
Joined: Wed Nov 06, 2013 6:04 pm

Re: Problem with phpseclib and PDO

Postby TerraFrost » Thu Nov 07, 2013 2:54 am

Code: Select all

$pdo = new PDO('mysql:host=localhost;dbname=dbname', 'username', 'password');
$stmt = $pdo->prepare("SELECT '-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----' AS public_key");
$row = $stmt->fetch();
$public_key = $row['public_key'];
$rsa = new Crypt_RSA();

Does that work (well echo out the public key) for you? It works for me..
Legendary Guard
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 1 guest