Qore Programming Language Reference Manual  1.8.0
Qore::SSLPrivateKey Class Reference

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

Inheritance diagram for Qore::SSLPrivateKey:

Public Member Methods

 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 ()
 Returns a copy of the private key object. More...
 
int getBitLength ()
 Returns the bit length of the private key. More...
 
binary getDER ()
 Returns a binary object in DER format representing the private key. More...
 
hash< auto > 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...
 
- Public Member Methods inherited from Qore::Serializable
 constructor ()
 The constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class.
 
 copy ()
 The copy constructor does not perform any action; this class is just used to mark a class as serializable by inheriting this class.
 
 serialize (OutputStream stream)
 converts the object to binary data representing the object More...
 
binary serialize ()
 converts the object to binary data representing the object More...
 
hash< SerializationInfoserializeToData ()
 converts the object to a serialization hash representing the object More...
 

Additional Inherited Members

- Static Public Member Methods inherited from Qore::Serializable
static auto deserialize (InputStream stream)
 Deserializes data produced with serialize() and returns the value represented by the data. More...
 
static auto deserialize (binary bin)
 Deserializes data produced with serialize() and returns the value represented by the data. More...
 
static auto deserialize (string bin)
 Deserializes data produced with serialize() and returns the value represented by the data. More...
 
static auto deserialize (hash< SerializationInfo > data)
 Deserializes data produced with serializeToData() and returns the value represented by the data. More...
 
static hash< SerializationInfodeserializeToData (InputStream stream)
 Deserializes data produced with serialize() and returns the value represented by the data. More...
 
static hash< SerializationInfodeserializeToData (binary bin)
 Deserializes data produced with serialize() and returns the value represented by the data. More...
 
static serialize (auto val, OutputStream stream)
 serializes the data and writes the serialized data to the given output stream More...
 
static binary serialize (auto val)
 serializes the data and returns the serialized data as a binary object More...
 
static hash< SerializationInfoserializeToData (auto val)
 converts the value to a serialization hash representing the value More...
 

Detailed Description

This class implements a container for private key data.

The SSLPrivateKey class supports data serialization; note that the serialized data is a representation of the data that does not require a password, so for source data that requires a password to use, the serialized representation of the private key should be protected carefully (transmitted only in an encrypted stream)

Member Function Documentation

◆ constructor() [1/2]

Qore::SSLPrivateKey::constructor ( binary  der)

Creates the SSLPrivateKey object from the data argument passed.

Parameters
derThe DER-encoded binary representation of the private key
Example:
SSLPrivateKey key(der);
Exceptions
SSLPRIVATEKEY-CONSTRUCTOR-ERRORerror in private key data

◆ constructor() [2/2]

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

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

Parameters
pemThe PEM-encoded text representation of the private key
passThe optional password or passphrase for the private key
Example:
SSLPrivateKey key(pem);
Exceptions
SSLPRIVATEKEY-CONSTRUCTOR-ERRORerror 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

◆ copy()

Qore::SSLPrivateKey::copy ( )

Returns a copy of the private key object.

Since
Qore 0.9

◆ getBitLength()

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();

◆ getDER()

binary Qore::SSLPrivateKey::getDER ( )

Returns a binary object in DER format representing the private key.

Code Flags:
RET_VALUE_ONLY
Example:
binary der = key.getDER();
Returns
a binary object in DER format representing the private key
Note
No password is required to use the DER data produced even if the object was originally created with a password
Exceptions
SSLPRIVATEKEY-ERRORcould not create DER data from private key data
Since
Qore 0.9

◆ getInfo()

hash<auto> 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:
Code Flags:
CONSTANT
Example:
hash<auto> h = key.getInfo();

◆ getPEM()

string Qore::SSLPrivateKey::getPEM ( )

Returns a string in PEM format representing the private key.

Returns
a string in PEM format representing the private key
Code Flags:
RET_VALUE_ONLY
Example:
string pem = key.getPEM();
Note
No password is required to use the PEM data produced even if the object was originally created with a password
Exceptions
SSLPRIVATEKEY-ERRORcould not create PEM string from private key data

◆ getType()

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();

◆ getVersion()

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