All Classes Namespaces Functions Variables Groups Pages
Qore::SSLPrivateKey Class Reference

This class implements a container for private key data. More...

## Public Member Functions

| constructor (string pem, *string pass)
| Creates the SSLPrivateKey object from the PEM-encoded text representation of the private key passed.
| constructor (binary der)
| Creates the SSLPrivateKey object from the data argument passed.
| copy ()
| Copying objects of this class is not supported, an exception will be thrown.
int | getBitLength ()
| Returns the bit length of the private key.
hash | getInfo ()
| Returns a hash of all information for the private key.
string | getPEM ()
| Returns a string in PEM format representing the private key.
string | getType ()
| Returns a string giving the algorithm used for the private key.
int | getVersion ()
| Returns a constant value of 1; do not use; only included for backwards-compatibility.

## Detailed Description

This class implements a container for private key data.

## Member Function Documentation

Qore::SSLPrivateKey::constructor | ( | string | pem,
|  | *string | pass
| ) |  |

Creates the SSLPrivateKey object from the PEM-encoded text representation of the private key passed.

Parameters

  pem | The PEM-encoded text representation of the private key
  pass | The optional password or passphrase for the private key

Example:
  my SSLPrivateKey $key($pem);

Exceptions

  SSLPRIVATEKEY-CONSTRUCTOR-ERROR | error in private key data

Since
  0.8.4: the deprecated functionality where the if the string passed was less than 200 bytes long, it was assumed to be a file name has been removed; the string is assumed to be the PEM-encoded private key itself

Qore::SSLPrivateKey::constructor | ( | binary | der | ) |

Creates the SSLPrivateKey object from the data argument passed.

Parameters

  der | The DER-encoded binary representation of the private key

Example:
  my SSLPrivateKey $key($der);

Exceptions

  SSLPRIVATEKEY-CONSTRUCTOR-ERROR | error in private key data

Qore::SSLPrivateKey::copy | ( |  | ) |

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

Exceptions

  SSLPRIVATEKEY-COPY-ERROR | SSLPrivateKey objects cannot be copied

int Qore::SSLPrivateKey::getBitLength | ( |  | ) |

Returns the bit length of the private key.

Returns
  the bit length of the private key

Code Flags:
  CONSTANT

Example:
  my int $len = $key.getBitLength();

hash Qore::SSLPrivateKey::getInfo | ( |  | ) |

Returns a hash of all information for the private key.

Returns
  a hash of all information for the private key with the following keys:
  - `"type"`: The type of private key (see SSLPrivateKey::getType())
  - `"version"`: The version of the private key (see SSLPrivateKey::getVersion())
  - `"bitLength"`: The bit length of the private key (see SSLPrivateKey::getBitLength())

Code Flags:
  CONSTANT

Example:
  my hash $h = $key.getInfo();

string Qore::SSLPrivateKey::getPEM | ( |  | ) |

Returns a string in PEM format representing the private key.

Returns
  a string in PEM format representing the private key

Example:
  my string $pem = $key.getPEM();

Exceptions

  SSLPRIVATEKEY-ERROR | could not create PEM string from private key data

string Qore::SSLPrivateKey::getType | ( |  | ) |

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

Returns
  a string giving the algorithm used for the private key (ex: `"RSA"`, `"RSA2"`, `"DSA"`, `"DSA1"`, `"DSA2"`, `"DAS3"`, `"DAS4"`, `"DH"`, `"unknown"`)

Code Flags:
  CONSTANT

Example:
  my string $str = $pkey.getType();

int Qore::SSLPrivateKey::getVersion | ( |  | ) |

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

Code Flags:
  CONSTANT

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.

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