QSslCertificate

Inheritance diagram of QSslCertificate

Synopsis

Functions

Static functions

  • def fromData (data[, format=QSsl.Pem])
  • def fromDevice (device[, format=QSsl.Pem])
  • def fromPath (path[, format=QSsl.Pem[, syntax=QRegExp.FixedString]])

Detailed Description

The PySide.QtNetwork.QSslCertificate class provides a convenient API for an X509 certificate.

PySide.QtNetwork.QSslCertificate stores an X509 certificate, and is commonly used to verify the identity and store information about the local host, a remotely connected peer, or a trusted third party Certificate Authority.

There are many ways to construct a PySide.QtNetwork.QSslCertificate . The most common way is to call QSslSocket.peerCertificate() , which returns a PySide.QtNetwork.QSslCertificate object, or QSslSocket.peerCertificateChain() , which returns a list of them. You can also load certificates from a DER (binary) or PEM (Base64) encoded bundle, typically stored as one or more local files, or in a Qt Resource.

You can call PySide.QtNetwork.QSslCertificate.isNull() to check if your certificate is null. By default, PySide.QtNetwork.QSslCertificate constructs a null certificate. To check if the certificate is valid, call PySide.QtNetwork.QSslCertificate.isValid() . A null certificate is invalid, but an invalid certificate is not necessarily null. If you want to reset all contents in a certificate, call PySide.QtNetwork.QSslCertificate.clear() .

After loading a certificate, you can find information about the certificate, its subject, and its issuer, by calling one of the many accessor functions, including PySide.QtNetwork.QSslCertificate.version() , PySide.QtNetwork.QSslCertificate.serialNumber() , PySide.QtNetwork.QSslCertificate.issuerInfo() and PySide.QtNetwork.QSslCertificate.subjectInfo() . You can call PySide.QtNetwork.QSslCertificate.effectiveDate() and PySide.QtNetwork.QSslCertificate.expiryDate() to check when the certificate starts being effective and when it expires. The PySide.QtNetwork.QSslCertificate.publicKey() function returns the certificate subject’s public key as a PySide.QtNetwork.QSslKey . You can call PySide.QtNetwork.QSslCertificate.issuerInfo() or PySide.QtNetwork.QSslCertificate.subjectInfo() to get detailed information about the certificate issuer and its subject.

Internally, PySide.QtNetwork.QSslCertificate is stored as an X509 structure. You can access this handle by calling PySide.QtNetwork.QSslCertificate.handle() , but the results are likely to not be portable.

class PySide.QtNetwork.QSslCertificate(device[, format=QSsl.Pem])
class PySide.QtNetwork.QSslCertificate([encoded=QByteArray()[, format=QSsl.Pem]])
class PySide.QtNetwork.QSslCertificate(other)
Parameters:

Constructs an identical copy of other .

PySide.QtNetwork.QSslCertificate.SubjectInfo

Describes keys that you can pass to QSslCertificate.issuerInfo() or QSslCertificate.subjectInfo() to get information about the certificate issuer or subject.

Constant Description
QSslCertificate.Organization “O” The name of the organization.
QSslCertificate.CommonName “CN” The common name; most often this is used to store the host name.
QSslCertificate.LocalityName “L” The locality.
QSslCertificate.OrganizationalUnitName “OU” The organizational unit name.
QSslCertificate.CountryName “C” The country.
QSslCertificate.StateOrProvinceName “ST” The state or province.
PySide.QtNetwork.QSslCertificate.alternateSubjectNames()
Return type:

Returns the list of alternative subject names for this certificate. The alternate subject names typically contain host names, optionally with wildcards, that are valid for this certificate.

These names are tested against the connected peer’s host name, if either the subject information for CommonName doesn’t define a valid host name, or the subject info name doesn’t match the peer’s host name.

PySide.QtNetwork.QSslCertificate.clear()

Clears the contents of this certificate, making it a null certificate.

PySide.QtNetwork.QSslCertificate.digest([algorithm=QCryptographicHash.Md5])
Parameters:algorithmPySide.QtCore.QCryptographicHash.Algorithm
Return type:PySide.QtCore.QByteArray
PySide.QtNetwork.QSslCertificate.effectiveDate()
Return type:PySide.QtCore.QDateTime

Returns the date-time that the certificate becomes valid, or an empty PySide.QtCore.QDateTime if this is a null certificate.

PySide.QtNetwork.QSslCertificate.expiryDate()
Return type:PySide.QtCore.QDateTime

Returns the date-time that the certificate expires, or an empty PySide.QtCore.QDateTime if this is a null certificate.

static PySide.QtNetwork.QSslCertificate.fromData(data[, format=QSsl.Pem])
Parameters:
Return type:

static PySide.QtNetwork.QSslCertificate.fromDevice(device[, format=QSsl.Pem])
Parameters:
Return type:

static PySide.QtNetwork.QSslCertificate.fromPath(path[, format=QSsl.Pem[, syntax=QRegExp.FixedString]])
Parameters:
Return type:

PySide.QtNetwork.QSslCertificate.handle()
Return type:PySide.QtCore.Qt::HANDLE

Returns a pointer to the native certificate handle, if there is one, or a null pointer otherwise.

You can use this handle, together with the native API, to access extended information about the certificate.

Warning

Use of this function has a high probability of being non-portable, and its return value may vary from platform to platform or change from minor release to minor release.

PySide.QtNetwork.QSslCertificate.isNull()
Return type:PySide.QtCore.bool

Returns true if this is a null certificate (i.e., a certificate with no contents); otherwise returns false.

By default, PySide.QtNetwork.QSslCertificate constructs a null certificate.

PySide.QtNetwork.QSslCertificate.isValid()
Return type:PySide.QtCore.bool

Returns true if this certificate is valid; otherwise returns false.

Note: Currently, this function only checks that the current data-time is within the date-time range during which the certificate is considered valid. No other checks are currently performed.

PySide.QtNetwork.QSslCertificate.issuerInfo(info)
Parameters:infoPySide.QtNetwork.QSslCertificate.SubjectInfo
Return type:unicode

Returns the issuer information for the subject from the certificate, or an empty string if there is no information for subject in the certificate.

PySide.QtNetwork.QSslCertificate.issuerInfo(tag)
Parameters:tagPySide.QtCore.QByteArray
Return type:unicode

Returns the issuer information for tag from the certificate, or an empty string if there is no information for tag in the certificate.

PySide.QtNetwork.QSslCertificate.__ne__(other)
Parameters:otherPySide.QtNetwork.QSslCertificate
Return type:PySide.QtCore.bool

Returns true if this certificate is not the same as other ; otherwise returns false.

PySide.QtNetwork.QSslCertificate.__eq__(other)
Parameters:otherPySide.QtNetwork.QSslCertificate
Return type:PySide.QtCore.bool

Returns true if this certificate is the same as other ; otherwise returns false.

PySide.QtNetwork.QSslCertificate.publicKey()
Return type:PySide.QtNetwork.QSslKey

Returns the certificate subject’s public key.

PySide.QtNetwork.QSslCertificate.serialNumber()
Return type:PySide.QtCore.QByteArray

Returns the certificate’s serial number string in decimal format. In case the serial number cannot be converted to decimal format (i.e. if it is bigger than 4294967295, which means it does not fit into 4 bytes), its hexadecimal version is returned.

PySide.QtNetwork.QSslCertificate.subjectInfo(info)
Parameters:infoPySide.QtNetwork.QSslCertificate.SubjectInfo
Return type:unicode

Returns the information for the subject , or an empty string if there is no information for subject in the certificate.

PySide.QtNetwork.QSslCertificate.subjectInfo(tag)
Parameters:tagPySide.QtCore.QByteArray
Return type:unicode

Returns the subject information for tag , or an empty string if there is no information for tag in the certificate.

PySide.QtNetwork.QSslCertificate.toDer()
Return type:PySide.QtCore.QByteArray

Returns this certificate converted to a DER (binary) encoded representation.

PySide.QtNetwork.QSslCertificate.toPem()
Return type:PySide.QtCore.QByteArray

Returns this certificate converted to a PEM (Base64) encoded representation.

PySide.QtNetwork.QSslCertificate.version()
Return type:PySide.QtCore.QByteArray

Returns the certificate’s version string.