Qore Programming Language Reference Manual 2.0.0
Loading...
Searching...
No Matches
Qore::SSLPrivateKey Class Reference

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

#include <QC_SSLPrivateKey.dox.h>

Inheritance diagram for Qore::SSLPrivateKey:
[legend]

Public Member Methods

 constructor (string pem, __7_ 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 ()
 Returns a copy of the private key object.
 
int getBitLength ()
 Returns the bit length of the private key.
 
binary getDER ()
 Returns a binary object in DER format representing the private key.
 
hash< autogetInfo ()
 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.
 
- 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, __7_ int flags)
 converts the object to binary data representing the object
 
binary serialize (__7_ int flags)
 converts the object to binary data representing the object
 
hash< SerializationInfoserializeToData (__7_ int flags)
 converts the object to a serialization hash representing the object
 

Additional Inherited Members

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

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,
__7_ 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