limal-ca-mgm
Static Public Member Functions
limal::ca_mgm::LocalManagement Class Reference

Functions for local certificate management. More...

#include <LocalManagement.hpp>

List of all members.

Static Public Member Functions

static void importAsLocalCertificate (const String &pkcs12File, const String &password, const String &destinationCAsDir, const String &destinationCertFile, const String &destinationKeyFile)
static void importAsLocalCertificate (const limal::ByteBuffer &pkcs12Data, const String &password, const String &destinationCAsDir, const String &destinationCertFile, const String &destinationKeyFile)
static void importCommonServerCertificate (const String &pkcs12File, const String &password)
static void importCommonServerCertificate (const limal::ByteBuffer &pkcs12Data, const String &password)
static CertificateData getCertificate (const String &file, FormatType type)
static CertificateData getCertificate (const limal::ByteBuffer &data, FormatType type)
static RequestData getRequest (const String &file, FormatType type)
static RequestData getRequest (const limal::ByteBuffer &data, FormatType type)
static CRLData getCRL (const String &file, FormatType type)
static CRLData getCRL (const limal::ByteBuffer &data, FormatType type)
static limal::ByteBuffer readFile (const String &file)
static void writeFile (const limal::ByteBuffer &data, const String &file, bool overwrite=true, mode_t mode=0644)
static limal::ByteBuffer x509Convert (const limal::ByteBuffer &certificate, FormatType inform, FormatType outform)
static limal::ByteBuffer rsaConvert (const limal::ByteBuffer &key, FormatType inform, FormatType outform, const String &inPassword, const String &outPassword, const String &algorithm="des3")
static limal::ByteBuffer crlConvert (const limal::ByteBuffer &crl, FormatType inform, FormatType outform)
static limal::ByteBuffer reqConvert (const limal::ByteBuffer &req, FormatType inform, FormatType outform)
static limal::ByteBuffer createPKCS12 (const limal::ByteBuffer &certificate, const limal::ByteBuffer &key, const String &inPassword, const String &outPassword, const limal::ByteBuffer &caCert, const String &caPath, bool withChain=false)
static limal::ByteBuffer pkcs12ToPEM (const limal::ByteBuffer &pkcs12, const String &inPassword, const String &outPassword, const String &algorithm="des3")

Detailed Description

Functions for local certificate management.

This class provides functions for local certificate management which are usefull on every host.


Member Function Documentation

static limal::ByteBuffer limal::ca_mgm::LocalManagement::createPKCS12 ( const limal::ByteBuffer certificate,
const limal::ByteBuffer key,
const String inPassword,
const String outPassword,
const limal::ByteBuffer caCert,
const String caPath,
bool  withChain = false 
) [static]

Create a PKCS12 bundle. Certificate and key has to be in PEM format.

Parameters:
certificatethe certificate in PEM format
keythe private key in PEM format
inPasswordthe password of key. If key is not encrypted use "".
outPasswordthe password of the pkcs12 file (empty not allowed)
caCertadditional certificates to include in this container
caPathset the path to the CA store
withChaininclude the entire certificate chain of certificate
Returns:
the PKCS12 file
static limal::ByteBuffer limal::ca_mgm::LocalManagement::crlConvert ( const limal::ByteBuffer crl,
FormatType  inform,
FormatType  outform 
) [static]

Convert a CRL from PEM/DER to DER/PEM format

Parameters:
crlthe CRL in PEM or DER format
informthe format of crl
outformthe output format
Returns:
the converted CRL
static CertificateData limal::ca_mgm::LocalManagement::getCertificate ( const String file,
FormatType  type 
) [static]

Parse a Certificate and return the data

Parameters:
filepath to the certificate file in PEM or DER format
typethe format of the certificate
Returns:
the parsed certificate data
static CertificateData limal::ca_mgm::LocalManagement::getCertificate ( const limal::ByteBuffer data,
FormatType  type 
) [static]

Parse a Certificate and return the data

Parameters:
datathe certificate data in PEM or DER format
typethe format of the certificate
Returns:
the parsed certificate data
static CRLData limal::ca_mgm::LocalManagement::getCRL ( const String file,
FormatType  type 
) [static]

Parse a CRL and return the data

Parameters:
filepath to the CRL file in PEM or DER format
typethe format of the CRL
Returns:
the parsed CRL data
static CRLData limal::ca_mgm::LocalManagement::getCRL ( const limal::ByteBuffer data,
FormatType  type 
) [static]

Parse a CRL and return the data

Parameters:
datathe CRL data in PEM or DER format
typethe format of the CRL
Returns:
the parsed CRL data
static RequestData limal::ca_mgm::LocalManagement::getRequest ( const String file,
FormatType  type 
) [static]

Parse a Request and return the data

Parameters:
filepath to the request file in PEM or DER format
typethe format of the request
Returns:
the parsed request data
static RequestData limal::ca_mgm::LocalManagement::getRequest ( const limal::ByteBuffer data,
FormatType  type 
) [static]

Parse a Request and return the data

Parameters:
datathe request data in PEM or DER format
typethe format of the request
Returns:
the parsed request data
static void limal::ca_mgm::LocalManagement::importAsLocalCertificate ( const String pkcs12File,
const String password,
const String destinationCAsDir,
const String destinationCertFile,
const String destinationKeyFile 
) [static]

Import a certificate to a specific destination

Parameters:
pkcs12Filefull path to a PKCS12 file with the certificates
passwordthe password for the PKCS12 file
destinationCAsDirpath to the directory where the CAs are stored
destinationCertFilethe path where the certificate should be stored
destinationKeyFilethe path where the private key should be stored
static void limal::ca_mgm::LocalManagement::importAsLocalCertificate ( const limal::ByteBuffer pkcs12Data,
const String password,
const String destinationCAsDir,
const String destinationCertFile,
const String destinationKeyFile 
) [static]

Import a certificate to a specific destination

Parameters:
pkcs12DataPKCS12 certificate data
passwordthe password for the PKCS12 file
destinationCAsDirpath to the directory where the CAs are stored
destinationCertFilethe path where the certificate should be stored
destinationKeyFilethe path where the private key should be stored
static void limal::ca_mgm::LocalManagement::importCommonServerCertificate ( const String pkcs12File,
const String password 
) [static]

Import a certificate as common server certificate. This function store the CAs to '/etc/ssl/certs', the certificate to '/etc/ssl/servercerts/servercert.pem' and the private key to '/etc/ssl/servercerts/serverkey.pem'.

Parameters:
pkcs12Filefull path to a PKCS12 file with the certificates
passwordthe password for the PKCS12 file
static void limal::ca_mgm::LocalManagement::importCommonServerCertificate ( const limal::ByteBuffer pkcs12Data,
const String password 
) [static]

Import a certificate as common server certificate. This function store the CAs to '/etc/ssl/certs', the certificate to '/etc/ssl/servercerts/servercert.pem' and the private key to '/etc/ssl/servercerts/serverkey.pem'.

Parameters:
pkcs12DataPKCS12 certificate data
passwordthe password for the PKCS12 file
static limal::ByteBuffer limal::ca_mgm::LocalManagement::pkcs12ToPEM ( const limal::ByteBuffer pkcs12,
const String inPassword,
const String outPassword,
const String algorithm = "des3" 
) [static]

Extract PKCS12 to PEM

Parameters:
pkcs12the PKCS12 file
inPasswordthe password of pkcs12
outPasswordthe new password for the private key. If outPasswort is "", the private key will not be encrypted.
algorithmthe encryption algorithm for the key valid values are: des, des3, aes128, aes192, aes256
Returns:
the certificates and private key
static limal::ByteBuffer limal::ca_mgm::LocalManagement::readFile ( const String file) [static]

Read a file from the harddisk and return the content as ByteBuffer Object

Parameters:
filethe path to the file to read
Returns:
the file content
static limal::ByteBuffer limal::ca_mgm::LocalManagement::reqConvert ( const limal::ByteBuffer req,
FormatType  inform,
FormatType  outform 
) [static]

Convert a Request from PEM/DER to DER/PEM format

Parameters:
reqthe Request in PEm or DER format
informthe format of req
outformthe output format
Returns:
the converted Request
static limal::ByteBuffer limal::ca_mgm::LocalManagement::rsaConvert ( const limal::ByteBuffer key,
FormatType  inform,
FormatType  outform,
const String inPassword,
const String outPassword,
const String algorithm = "des3" 
) [static]

Convert a rsa key from PEM/DER to DER/PEM. This function can also be used to set a new password or remove the encryption from the key. An encrypted key is only available if the format is PEM.

Parameters:
keythe key data
informthe format of the key data
outformthe output format of the key
inPasswordthe password for the key data. "" == no password set.
outPasswordthe new password for the key. "" == no password for the new key.
algorithmthe encryption algorithm for the key valid values are: des, des3, aes128, aes192, aes256
Returns:
the converted key
static void limal::ca_mgm::LocalManagement::writeFile ( const limal::ByteBuffer data,
const String file,
bool  overwrite = true,
mode_t  mode = 0644 
) [static]

Write data into a file

Parameters:
datathe data to write
filethe path to the file
overwriteif this is true and the file exists it will be overwritten with the new data, if false it throws an exception
modethe file permissions for the file (only if it is new created)
static limal::ByteBuffer limal::ca_mgm::LocalManagement::x509Convert ( const limal::ByteBuffer certificate,
FormatType  inform,
FormatType  outform 
) [static]

Convert a certificate from PEM/DER to DER/PEM format

Parameters:
certificatethe certificate in PEM or DER Format
informformat of certificate
outformthe output format
Returns:
the converted certificate in the new format

The documentation for this class was generated from the following file: