QCA::Certificate

#include <QtCrypto>

Inheritance diagram for QCA::Certificate:

Public Member Functions

 Certificate ()
 
 Certificate (const QString &fileName)
 
 Certificate (const CertificateOptions &opts, const PrivateKey &key, const QString &provider=QString())
 
 Certificate (const Certificate &from)
 
void change (CertContext *c)
 
QString commonName () const
 
Constraints constraints () const
 
QStringList crlLocations () const
 
bool isCA () const
 
bool isIssuerOf (const Certificate &other) const
 
bool isNull () const
 
bool isSelfSigned () const
 
CertificateInfo issuerInfo () const
 
CertificateInfoOrdered issuerInfoOrdered () const
 
QByteArray issuerKeyId () const
 
QStringList issuerLocations () const
 
bool matchesHostName (const QString &host) const
 
QDateTime notValidAfter () const
 
QDateTime notValidBefore () const
 
QStringList ocspLocations () const
 
bool operator!= (const Certificate &other) const
 
Certificateoperator= (const Certificate &from)
 
bool operator== (const Certificate &a) const
 
int pathLimit () const
 
QStringList policies () const
 
BigInteger serialNumber () const
 
SignatureAlgorithm signatureAlgorithm () const
 
CertificateInfo subjectInfo () const
 
CertificateInfoOrdered subjectInfoOrdered () const
 
QByteArray subjectKeyId () const
 
PublicKey subjectPublicKey () const
 
QByteArray toDER () const
 
QString toPEM () const
 
bool toPEMFile (const QString &fileName) const
 
Validity validate (const CertificateCollection &trusted, const CertificateCollection &untrusted, UsageMode u=UsageAny, ValidateFlags vf=ValidateAll) const
 
- Public Member Functions inherited from QCA::Algorithm
 Algorithm (const Algorithm &from)
 
void change (Provider::Context *c)
 
void change (const QString &type, const QString &provider)
 
Provider::Contextcontext ()
 
const Provider::Contextcontext () const
 
Algorithmoperator= (const Algorithm &from)
 
Providerprovider () const
 
Provider::ContexttakeContext ()
 
QString type () const
 

Static Public Member Functions

static Certificate fromDER (const QByteArray &a, ConvertResult *result=nullptr, const QString &provider=QString())
 
static Certificate fromPEM (const QString &s, ConvertResult *result=nullptr, const QString &provider=QString())
 
static Certificate fromPEMFile (const QString &fileName, ConvertResult *result=nullptr, const QString &provider=QString())
 

Additional Inherited Members

- Protected Member Functions inherited from QCA::Algorithm
 Algorithm ()
 
 Algorithm (const QString &type, const QString &provider)
 

Detailed Description

Public Key (X.509) certificate.

This class contains one X.509 certificate

Examples:
certtest.cpp, publickeyexample.cpp, sslservtest.cpp, and ssltest.cpp.

Definition at line 848 of file qca_cert.h.

Constructor & Destructor Documentation

QCA::Certificate::Certificate ( )

Create an empty Certificate.

QCA::Certificate::Certificate ( const QString fileName)

Create a Certificate from a PEM encoded file.

Parameters
fileNamethe name (and path, if required) of the file that contains the PEM encoded certificate
QCA::Certificate::Certificate ( const CertificateOptions opts,
const PrivateKey key,
const QString provider = QString() 
)

Create a Certificate with specified options and a specified private key.

Parameters
optsthe options to use
keythe private key for this certificate
providerthe provider to use to create this key, if a particular provider is required
QCA::Certificate::Certificate ( const Certificate from)

Standard copy constructor.

Parameters
fromthe certificate to copy from

Member Function Documentation

void QCA::Certificate::change ( CertContext c)
Parameters
ccontext (internal)
QString QCA::Certificate::commonName ( ) const

The common name of the subject of the certificate.

Common names are normally the name of a person, company or organisation

Examples:
ssltest.cpp.
Constraints QCA::Certificate::constraints ( ) const

The constraints that apply to this certificate.

QStringList QCA::Certificate::crlLocations ( ) const

List of URI locations for CRL files.

Each URI refers to the same CRL file

static Certificate QCA::Certificate::fromDER ( const QByteArray a,
ConvertResult result = nullptr,
const QString provider = QString() 
)
static

Import the certificate from DER.

Parameters
athe array containing the certificate in DER format
resulta pointer to a ConvertResult, which if not-null will be set to the conversion status
providerthe provider to use, if a specific provider is required
Returns
the Certificate corresponding to the certificate in the provided array
static Certificate QCA::Certificate::fromPEM ( const QString s,
ConvertResult result = nullptr,
const QString provider = QString() 
)
static

Import the certificate from PEM format.

Parameters
sthe string containing the certificate in PEM format
resulta pointer to a ConvertResult, which if not-null will be set to the conversion status
providerthe provider to use, if a specific provider is required
Returns
the Certificate corresponding to the certificate in the provided string
Examples:
sslservtest.cpp, and ssltest.cpp.
static Certificate QCA::Certificate::fromPEMFile ( const QString fileName,
ConvertResult result = nullptr,
const QString provider = QString() 
)
static

Import the certificate from a file.

Parameters
fileNamethe name (and path, if required) of the file containing the certificate in PEM format
resulta pointer to a ConvertResult, which if not-null will be set to the conversion status
providerthe provider to use, if a specific provider is required
Returns
the Certificate corresponding to the certificate in the provided string
bool QCA::Certificate::isCA ( ) const

Test if the Certificate is valid as a Certificate Authority.

Returns
true if the Certificate is valid as a Certificate Authority
Examples:
certtest.cpp.
bool QCA::Certificate::isIssuerOf ( const Certificate other) const

Test if the Certificate has signed another Certificate object and is therefore the issuer.

Parameters
otherthe certificate to test
Returns
true if this certificate is the issuer of the argument
bool QCA::Certificate::isNull ( ) const

Test if the certificate is empty (null)

Returns
true if the certificate is null
Examples:
publickeyexample.cpp.
bool QCA::Certificate::isSelfSigned ( ) const

Test if the Certificate is self-signed.

Returns
true if the certificate is self-signed
Examples:
certtest.cpp.
CertificateInfo QCA::Certificate::issuerInfo ( ) const

Properties of the issuer of the certificate.

See also
subjectInfo for how the return value works.
Examples:
certtest.cpp.
CertificateInfoOrdered QCA::Certificate::issuerInfoOrdered ( ) const

Properties of the issuer of the certificate, as an ordered list (QList of CertificateInfoPair).

This allows access to the certificate information in the same order as they appear in a certificate. Each pair in the list has a type and a value.

See also
issuerInfo for an unordered version
subjectInfoOrdered for the ordered information on the subject
CertificateInfoPair for the elements in the list
QByteArray QCA::Certificate::issuerKeyId ( ) const

The key identifier associated with the issuer.

QStringList QCA::Certificate::issuerLocations ( ) const

List of URI locations for issuer certificate files.

Each URI refers to the same issuer file

bool QCA::Certificate::matchesHostName ( const QString host) const

Test if the subject of the certificate matches a specified host name.

This will return true (indicating a match), if the specified host name meets the RFC 2818 validation rules with this certificate.

If the host is an internationalized domain name, then it must be provided in unicode format, not in IDNA ACE/punycode format.

Parameters
hostthe name of the host to compare to
QDateTime QCA::Certificate::notValidAfter ( ) const

The latest date that the certificate is valid.

Examples:
certtest.cpp, and ssltest.cpp.
QDateTime QCA::Certificate::notValidBefore ( ) const

The earliest date that the certificate is valid.

Examples:
certtest.cpp, and ssltest.cpp.
QStringList QCA::Certificate::ocspLocations ( ) const

List of URI locations for OCSP services.

bool QCA::Certificate::operator!= ( const Certificate other) const
inline

Inequality operator.

Parameters
otherthe certificate to compare this certificate with

Definition at line 1163 of file qca_cert.h.

Certificate& QCA::Certificate::operator= ( const Certificate from)

Standard assignment operator.

Parameters
fromthe Certificate to assign from
bool QCA::Certificate::operator== ( const Certificate a) const

Test for equality of two certificates.

Parameters
athe certificate to compare this certificate with
Returns
true if the two certificates are the same
int QCA::Certificate::pathLimit ( ) const

The upper bound of the number of links in the certificate chain, if any.

QStringList QCA::Certificate::policies ( ) const

The policies that apply to this certificate.

Policies are specified as strings containing OIDs

BigInteger QCA::Certificate::serialNumber ( ) const

The serial number of the certificate.

Examples:
certtest.cpp.
SignatureAlgorithm QCA::Certificate::signatureAlgorithm ( ) const

The signature algorithm used for the signature on this certificate.

CertificateInfo QCA::Certificate::subjectInfo ( ) const

Properties of the subject of the certificate, as a QMultiMap.

This is the method that provides information on the subject organisation, common name, DNS name, and so on. The list of information types (i.e. the key to the multi-map) is a CertificateInfoType. The values are a list of QString.

An example of how you can iterate over the list is:

foreach( QString dns, info.values(QCA::DNS) )
{
std::cout << " " << qPrintable(dns) << std::endl;
}
Examples:
certtest.cpp.
CertificateInfoOrdered QCA::Certificate::subjectInfoOrdered ( ) const

Properties of the subject of the certificate, as an ordered list (QList of CertificateInfoPair).

This allows access to the certificate information in the same order as they appear in a certificate. Each pair in the list has a type and a value.

For example:

CertificateInfoOrdered info = cert.subjectInfoOrdered();
// info[0].type == CommonName
// info[0].value == "example.com"
See also
subjectInfo for an unordered version
issuerInfoOrdered for the ordered information on the issuer
CertificateInfoPair for the elements in the list
QByteArray QCA::Certificate::subjectKeyId ( ) const

The key identifier associated with the subject.

PublicKey QCA::Certificate::subjectPublicKey ( ) const

The public key associated with the subject of the certificate.

QByteArray QCA::Certificate::toDER ( ) const

Export the Certificate into a DER format.

QString QCA::Certificate::toPEM ( ) const

Export the Certificate into a PEM format.

Examples:
certtest.cpp, and ssltest.cpp.
bool QCA::Certificate::toPEMFile ( const QString fileName) const

Export the Certificate into PEM format in a file.

Parameters
fileNamethe name of the file to use
Validity QCA::Certificate::validate ( const CertificateCollection trusted,
const CertificateCollection untrusted,
UsageMode  u = UsageAny,
ValidateFlags  vf = ValidateAll 
) const

Check the validity of a certificate.

Parameters
trusteda collection of trusted certificates
untrusteda collection of additional certificates, not necessarily trusted
uthe use required for the certificate
vfthe conditions to validate
Note
This function may block

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 6 2020 23:02:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.