4.11. SSLPrivateKey Class

SSLPrivateKey objects are containers for private key data.

Table 4.528. SSLPrivateKey Class Method Overview

Method

Except?

Description

SSLPrivateKey::constructor(string $key_pem, string $pass = "")

SSLPrivateKey::constructor(binary $key_der)

Y

Creates the SSLPrivateKey object from the data argument passed; as a deprecated, backwards-compatibilty extension, if the string variant is used and a string less then 120 bytes long is passed, it is taken as a filename to use to load the private key data from in PEM format. In this case PO_NO_FILESYSTEM is checked at run-time; if set, and exception is thrown.

SSLPrivateKey::destructor()

N

Destroys the SSLPrivateKey object.

SSLPrivateKey::copy()

Y

Copying objects of this class is not supported, an exception will be thrown.

string SSLPrivateKey::getType()

N

Returns the algorithm used for the private key.

int SSLPrivateKey::getVersion()

N

Returns a constant 1; do not use; only included for backwards compatibility.

int SSLPrivateKey::getBitLength()

N

Returns the bit length of the private key.

hash SSLPrivateKey::getInfo()

N

Returns a hash of all information for the private key.


4.11.1. SSLPrivateKey::constructor()

Synopsis

Creates the SSLPrivateKey object from the data argument passed.

As a deprecated, backwards-compatibilty extension, if the string variant is used and a string less then 120 bytes long is passed, it is taken as a filename to use to load the private key data from in PEM format. In this case PO_NO_FILESYSTEM is checked at run-time; if set, and exception is thrown. Do not use this feature; load the file first and pass the data to the constructor instead. This functionality will be removed in a future release of Qore.

Prototype

SSLPrivateKey::constructor(string $key_pem, string $pass = "")

SSLPrivateKey::constructor(binary $key_der)

Example
my SSLPrivateKey $pkey($data);

Table 4.529. Arguments for SSLPrivateKey::constructor()

Argument

Description

string $key_pem, string $pass = ""

The PEM-encoded text representation of the private key and optionally its passphrase.

binary $key_der

The DER-encoded binary representation of the private key.


Table 4.530. Exceptions thrown by SSLPrivateKey::constructor()

err

desc

SSLPRIVATEKEY-CONSTRUCTOR-ERROR

invalid format, invalid or missing password, etc


4.11.2. SSLPrivateKey::destructor()

Synopsis

Destroys the SSLPrivateKey object.

Example
delete $pkey;

4.11.3. SSLPrivateKey::copy()

Synopsis

Copying objects of this class is not supported, an exception will be thrown.

Table 4.531. Exceptions thrown by SSLPrivateKey::copy()

err

desc

SSLPRIVATEKEY-COPY-ERROR

objects of this class may not be copied


4.11.4. SSLPrivateKey::getType()

Synopsis

Returns a string giving the algorithm used for the private key.

Prototype

string SSLPrivateKey::getType()

Example
$str = $pkey.getType();

Table 4.532. Return Values for SSLPrivateKey::getType()

Return Type

Description

string

Returns values include: RSA, RSA2, DSA, DSA1, DSA2, DSA3, DSA4, DH, and unknown


4.11.5. SSLPrivateKey::getVersion()

Synopsis

Returns a constant value of 1; do not use; only included for backwards-compatibility.

The openssl library never put any usable value into the internal fields that were used to provide this information; newer versions of openssl do not expose this information at all, therefore this method now returns a constant value of 1 for backwards-compatibility.

Prototype

int SSLPrivateKey::getVersion()

Example
$int = $pkey.getVersion();

Table 4.533. Return Values for SSLPrivateKey::getVersion()

Return Type

Description

int

Always returns a value of 1.


4.11.6. SSLPrivateKey::getBitLength()

Synopsis

Returns the bit length of the private key.

Prototype

int SSLPrivateKey::getBitLength()

Example
$int = $pkey.getBitLength();

Table 4.534. Return Values for SSLPrivateKey::getBitLength()

Return Type

Description

int

The bit length of the private key.


4.11.7. SSLPrivateKey::getInfo()

Synopsis

hash SSLPrivateKey::getInfo()

Prototype
SSLPrivateKey::getInfo()
Example
$hash = $pkey.getInfo();

Table 4.535. Return Values for SSLPrivateKey::getInfo()

Return Type

Description

hash

Keys are 'type', 'version', and 'bitLength' corresponding to the algorithm type, the version, and the bit length of the key respectively.