QSslCertificateclass provides a convenient API for an X509 certificate. 更多 …
def
__eq__
(other)
def
__ne__
(other)
def
clear
()
def
digest
([algorithm=QCryptographicHash.Md5])
def
effectiveDate
()
def
expiryDate
()
def
extensions
()
def
handle
()
def
isBlacklisted
()
def
isNull
()
def
isSelfSigned
()
def
issuerDisplayName
()
def
issuerInfo
(attribute)
def
issuerInfo
(info)
def
issuerInfoAttributes
()
def
publicKey
()
def
serialNumber
()
def
subjectAlternativeNames
()
def
subjectDisplayName
()
def
subjectInfo
(attribute)
def
subjectInfo
(info)
def
subjectInfoAttributes
()
def
swap
(other)
def
toDer
()
def
toPem
()
def
toText
()
def
version
()
def
fromData
(data[, format=QSsl.Pem])
def
fromDevice
(device[, format=QSsl.Pem])
def
fromPath
(path, format, syntax)
def
fromPath
(path[, format=QSsl.Pem[, syntax=PatternSyntax.FixedString]])
def
importPkcs12
(device, key, cert[, caCertificates=None[, passPhrase=QByteArray()]])
def
verify
(certificateChain[, hostName=””])
QSslCertificatestores 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
QSslCertificate. The most common way is to callpeerCertificate(), which returns aQSslCertificateobject, orpeerCertificateChain(), 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.可以调用
isNull()to check if your certificate is null. By default,QSslCertificateconstructs a null certificate. A null certificate is invalid, but an invalid certificate is not necessarily null. If you want to reset all contents in a certificate, callclear().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
version(),serialNumber(),issuerInfo()andsubjectInfo(). You can calleffectiveDate()andexpiryDate()to check when the certificate starts being effective and when it expires. ThepublicKey()function returns the certificate subject’s public key as aQSslKey. You can callissuerInfo()orsubjectInfo()to get detailed information about the certificate issuer and its subject.内部,
QSslCertificateis stored as an X509 structure. You can access this handle by callinghandle(), but the results are likely to not be portable.
QSslCertificate
(
device
[
,
format=QSsl.Pem
]
)
¶
QSslCertificate([data=QByteArray()[, format=QSsl.Pem]])
QSslCertificate(other)
- param format
EncodingFormat- param device
QIODevice- param other
- param data
QByteArray
构造
QSslCertificate
by reading
format
encoded data from
device
and using the first certificate found. You can later call
isNull()
to see if
device
contained a certificate, and if this certificate was loaded successfully.
Constructs an identical copy of
other
.
PySide2.QtNetwork.QSslCertificate.
SubjectInfo
¶
Describes keys that you can pass to
issuerInfo()
or
subjectInfo()
to get information about the certificate issuer or subject.
|
常量 |
描述 |
|---|---|
|
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. |
|
QSslCertificate.DistinguishedNameQualifier |
The distinguished name qualifier |
|
QSslCertificate.SerialNumber |
The certificate’s serial number |
|
QSslCertificate.EmailAddress |
The email address associated with the certificate |
PySide2.QtNetwork.QSslCertificate.
PatternSyntax
¶
New in version 5.15.
PySide2.QtNetwork.QSslCertificate.
clear
(
)
¶
Clears the contents of this certificate, making it a null certificate.
另请参阅
PySide2.QtNetwork.QSslCertificate.
digest
(
[
algorithm=QCryptographicHash.Md5
]
)
¶
algorithm
–
Algorithm
QByteArray
Returns a cryptographic digest of this certificate. By default, an MD5 digest will be generated, but you can also specify a custom
algorithm
.
PySide2.QtNetwork.QSslCertificate.
effectiveDate
(
)
¶
QDateTime
Returns the date-time that the certificate becomes valid, or an empty
QDateTime
if this is a null certificate.
另请参阅
PySide2.QtNetwork.QSslCertificate.
expiryDate
(
)
¶
QDateTime
Returns the date-time that the certificate expires, or an empty
QDateTime
if this is a null certificate.
另请参阅
PySide2.QtNetwork.QSslCertificate.
extensions
(
)
¶
Returns a list containing the X509 extensions of this certificate.
PySide2.QtNetwork.QSslCertificate.
fromData
(
data
[
,
format=QSsl.Pem
]
)
¶
data
–
QByteArray
format
–
EncodingFormat
Searches for and parses all certificates in
data
that are encoded in the specified
format
and returns them in a list of certificates.
另请参阅
PySide2.QtNetwork.QSslCertificate.
fromDevice
(
device
[
,
format=QSsl.Pem
]
)
¶
device
–
QIODevice
format
–
EncodingFormat
Searches for and parses all certificates in
device
that are encoded in the specified
format
and returns them in a list of certificates.
另请参阅
PySide2.QtNetwork.QSslCertificate.
fromPath
(
path
,
format
,
syntax
)
¶
path – unicode
format
–
EncodingFormat
syntax
–
PatternSyntax
注意
此函数被弃用。
PySide2.QtNetwork.QSslCertificate.
fromPath
(
path
[
,
format=QSsl.Pem
[
,
syntax=PatternSyntax.FixedString
]
]
)
¶
path – unicode
format
–
EncodingFormat
syntax
–
PatternSyntax
PySide2.QtNetwork.QSslCertificate.
handle
(
)
¶
Qt::HANDLE
Returns a pointer to the native certificate handle, if there is one, else
None
.
You can use this handle, together with the native API, to access extended information about the certificate.
警告
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.
PySide2.QtNetwork.QSslCertificate.
importPkcs12
(
device
,
key
,
cert
[
,
caCertificates=None
[
,
passPhrase=QByteArray()
]
]
)
¶
device
–
QIODevice
key
–
QSslKey
cert
–
QSslCertificate
caCertificates
–
QList
passPhrase
–
QByteArray
bool
Imports a PKCS#12 (pfx) file from the specified
device
. A PKCS#12 file is a bundle that can contain a number of certificates and keys. This method reads a single
key
, its
certificate
and any associated
caCertificates
from the bundle. If a
passPhrase
is specified then this will be used to decrypt the bundle. Returns
true
if the PKCS#12 file was successfully loaded.
注意
device
must be open and ready to be read from.
PySide2.QtNetwork.QSslCertificate.
isBlacklisted
(
)
¶
bool
返回
true
if this certificate is blacklisted; otherwise returns
false
.
另请参阅
PySide2.QtNetwork.QSslCertificate.
isNull
(
)
¶
bool
返回
true
if this is a null certificate (i.e., a certificate with no contents); otherwise returns
false
.
默认情况下,
QSslCertificate
constructs a null certificate.
另请参阅
PySide2.QtNetwork.QSslCertificate.
isSelfSigned
(
)
¶
bool
返回
true
if this certificate is self signed; otherwise returns
false
.
A certificate is considered self-signed its issuer and subject are identical.
PySide2.QtNetwork.QSslCertificate.
issuerDisplayName
(
)
¶
unicode
Returns a name that describes the issuer. It returns the
CommonName
if available, otherwise falls back to the first
Organization
or the first
OrganizationalUnitName
.
另请参阅
PySide2.QtNetwork.QSslCertificate.
issuerInfo
(
attribute
)
¶
attribute
–
QByteArray
字符串列表
PySide2.QtNetwork.QSslCertificate.
issuerInfo
(
info
)
¶
info
–
SubjectInfo
字符串列表
Returns the issuer information for the
subject
from the certificate, or an empty list if there is no information for
subject
in the certificate. There can be more than one entry of each type.
另请参阅
PySide2.QtNetwork.QSslCertificate.
issuerInfoAttributes
(
)
¶
Returns a list of the attributes that have values in the issuer information of this certificate. The information associated with a given attribute can be accessed using the
issuerInfo()
method. Note that this list may include the OIDs for any elements that are not known by the SSL backend.
另请参阅
PySide2.QtNetwork.QSslCertificate.
__ne__
(
other
)
¶
other
–
QSslCertificate
bool
返回
true
if this certificate is not the same as
other
;否则返回
false
.
PySide2.QtNetwork.QSslCertificate.
__eq__
(
other
)
¶
other
–
QSslCertificate
bool
返回
true
if this certificate is the same as
other
;否则返回
false
.
PySide2.QtNetwork.QSslCertificate.
publicKey
(
)
¶
Returns the certificate subject’s public key.
PySide2.QtNetwork.QSslCertificate.
serialNumber
(
)
¶
QByteArray
Returns the certificate’s serial number string in hexadecimal format.
PySide2.QtNetwork.QSslCertificate.
subjectAlternativeNames
(
)
¶
Returns the list of alternative subject names for this certificate. The alternative 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.
另请参阅
PySide2.QtNetwork.QSslCertificate.
subjectDisplayName
(
)
¶
unicode
Returns a name that describes the subject. It returns the
CommonName
if available, otherwise falls back to the first
Organization
or the first
OrganizationalUnitName
.
另请参阅
PySide2.QtNetwork.QSslCertificate.
subjectInfo
(
info
)
¶
info
–
SubjectInfo
字符串列表
Returns the information for the
subject
, or an empty list if there is no information for
subject
in the certificate. There can be more than one entry of each type.
另请参阅
PySide2.QtNetwork.QSslCertificate.
subjectInfo
(
attribute
)
¶
attribute
–
QByteArray
字符串列表
PySide2.QtNetwork.QSslCertificate.
subjectInfoAttributes
(
)
¶
Returns a list of the attributes that have values in the subject information of this certificate. The information associated with a given attribute can be accessed using the
subjectInfo()
method. Note that this list may include the OIDs for any elements that are not known by the SSL backend.
另请参阅
PySide2.QtNetwork.QSslCertificate.
swap
(
other
)
¶
other
–
QSslCertificate
Swaps this certificate instance with
other
。此函数非常快,且从不失败。
PySide2.QtNetwork.QSslCertificate.
toDer
(
)
¶
QByteArray
Returns this certificate converted to a DER (binary) encoded representation.
PySide2.QtNetwork.QSslCertificate.
toPem
(
)
¶
QByteArray
Returns this certificate converted to a PEM (Base64) encoded representation.
PySide2.QtNetwork.QSslCertificate.
toText
(
)
¶
unicode
Returns this certificate converted to a human-readable text representation.
PySide2.QtNetwork.QSslCertificate.
verify
(
certificateChain
[
,
hostName=""
]
)
¶
certificateChain –
hostName – unicode
Verifies a certificate chain. The chain to be verified is passed in the
certificateChain
parameter. The first certificate in the list should be the leaf certificate of the chain to be verified. If
hostName
is specified then the certificate is also checked to see if it is valid for the specified host name.
Note that the root (CA) certificate should not be included in the list to be verified, this will be looked up automatically either using the CA list specified by
defaultCaCertificates()
or, if possible, it will be loaded on demand on Unix.
PySide2.QtNetwork.QSslCertificate.
version
(
)
¶
QByteArray
Returns the certificate’s version string.