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

## 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:
  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:
  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:
  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:
  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:
  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:
  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