• PySide 模块
  • PySide.QtNetwork
  • 内容表

    上一话题

    QAuthenticator

    下一话题

    QSslError

    QSslConfiguration

    详细描述

    PySide.QtNetwork.QSslConfiguration class holds the configuration and state of an SSL connection

    PySide.QtNetwork.QSslConfiguration is used by Qt networking classes to relay information about an open SSL connection and to allow the application to control certain features of that connection.

    The settings that PySide.QtNetwork.QSslConfiguration currently supports are:

    • The SSL/TLS protocol to be used
    • The certificate to be presented to the peer during connection and its associated private key
    • The ciphers allowed to be used for encrypting the connection
    • The list of Certificate Authorities certificates that are used to validate the peer's certificate

    These settings are applied only during the connection handshake. Setting them after the connection has been established has no effect.

    The state that PySide.QtNetwork.QSslConfiguration supports are:

    • The certificate the peer presented during handshake, along with the chain leading to a CA certificate
    • The cipher used to encrypt this session

    The state can only be obtained once the SSL connection starts, but not necessarily before it's done. Some settings may change during the course of the SSL connection without need to restart it (for instance, the cipher can be changed over time).

    State in PySide.QtNetwork.QSslConfiguration objects cannot be changed.

    PySide.QtNetwork.QSslConfiguration can be used with PySide.QtNetwork.QSslSocket and the Network Access API.

    Note that changing settings in PySide.QtNetwork.QSslConfiguration is not enough to change the settings in the related SSL connection. You must call setSslConfiguration on a modified PySide.QtNetwork.QSslConfiguration object to achieve that. The following example illustrates how to change the protocol to TLSv1 in a PySide.QtNetwork.QSslSocket 对象:

    config = sslSocket.sslConfiguration()
    config.setProtocol(QSsl.TlsV1)
    sslSocket.setSslConfiguration(config)
    										

    PySide.QtNetwork.QSslSocket , PySide.QtNetwork.QNetworkAccessManager , QSslSocket.sslConfiguration() , QSslSocket.setSslConfiguration()

    class PySide.QtNetwork. QSslConfiguration
    class PySide.QtNetwork. QSslConfiguration ( other )
    参数: other PySide.QtNetwork.QSslConfiguration

    Constructs an empty SSL configuration. This configuration contains no valid settings and the state will be empty. PySide.QtNetwork.QSslConfiguration.isNull() will return true after this constructor is called.

    Once any setter methods are called, PySide.QtNetwork.QSslConfiguration.isNull() will return false.

    Copies the configuration and state of other 。若 other is null, this object will be null too.

    PySide.QtNetwork.QSslConfiguration. caCertificates ( )
    返回类型:

    Returns this connection's CA certificate database. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate. It can be modified prior to the handshake with PySide.QtNetwork.QSslConfiguration.setCaCertificates() , or with PySide.QtNetwork.QSslSocket ‘s PySide.QtNetwork.QSslSocket.addCaCertificate() and PySide.QtNetwork.QSslSocket.addCaCertificates() .

    PySide.QtNetwork.QSslConfiguration. ciphers ( )
    返回类型:

    Returns this connection's current cryptographic cipher suite. This list is used during the handshake phase for choosing a session cipher. The returned list of ciphers is ordered by descending preference. (i.e., the first cipher in the list is the most preferred cipher). The session cipher will be the first one in the list that is also supported by the peer.

    By default, the handshake phase can choose any of the ciphers supported by this system's SSL libraries, which may vary from system to system. The list of ciphers supported by this system's SSL libraries is returned by QSslSocket.supportedCiphers() . You can restrict the list of ciphers used for choosing the session cipher for this socket by calling PySide.QtNetwork.QSslConfiguration.setCiphers() with a subset of the supported ciphers. You can revert to using the entire set by calling PySide.QtNetwork.QSslConfiguration.setCiphers() with the list returned by QSslSocket.supportedCiphers() .

    static PySide.QtNetwork.QSslConfiguration. defaultConfiguration ( )
    返回类型: PySide.QtNetwork.QSslConfiguration

    Returns the default SSL configuration to be used in new SSL connections.

    The default SSL configuration consists of:

    • no local certificate and no private key
    • protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used)
    • the system's default CA certificate list
    • the cipher list equal to the list of the SSL libraries' supported SSL ciphers
    PySide.QtNetwork.QSslConfiguration. isNull ( )
    返回类型: PySide.QtCore.bool

    Returns true if this is a null PySide.QtNetwork.QSslConfiguration 对象。

    A PySide.QtNetwork.QSslConfiguration object is null if it has been default-constructed and no setter methods have been called.

    PySide.QtNetwork.QSslConfiguration. localCertificate ( )
    返回类型: PySide.QtNetwork.QSslCertificate

    Returns the certificate to be presented to the peer during the SSL handshake process.

    PySide.QtNetwork.QSslConfiguration. __ne__ ( other )
    参数: other PySide.QtNetwork.QSslConfiguration
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtNetwork.QSslConfiguration differs from other . Two PySide.QtNetwork.QSslConfiguration objects are considered different if any state or setting is different.

    另请参阅

    PySide.QtNetwork.QSslConfiguration.operator==()

    PySide.QtNetwork.QSslConfiguration. __eq__ ( other )
    参数: other PySide.QtNetwork.QSslConfiguration
    返回类型: PySide.QtCore.bool

    返回 true,若此 PySide.QtNetwork.QSslConfiguration object is equal to other .

    Two PySide.QtNetwork.QSslConfiguration objects are considered equal if they have the exact same settings and state.

    另请参阅

    PySide.QtNetwork.QSslConfiguration.operator!=()

    PySide.QtNetwork.QSslConfiguration. peerCertificate ( )
    返回类型: PySide.QtNetwork.QSslCertificate

    Returns the peer's digital certificate (i.e., the immediate certificate of the host you are connected to), or a null certificate, if the peer has not assigned a certificate.

    The peer certificate is checked automatically during the handshake phase, so this function is normally used to fetch the certificate for display or for connection diagnostic purposes. It contains information about the peer, including its host name, the certificate issuer, and the peer's public key.

    Because the peer certificate is set during the handshake phase, it is safe to access the peer certificate from a slot connected to the QSslSocket.sslErrors() signal, QNetworkReply.sslErrors() signal, or the QSslSocket.encrypted() 信号。

    If a null certificate is returned, it can mean the SSL handshake failed, or it can mean the host you are connected to doesn't have a certificate, or it can mean there is no connection.

    If you want to check the peer's complete chain of certificates, use PySide.QtNetwork.QSslConfiguration.peerCertificateChain() to get them all at once.

    PySide.QtNetwork.QSslConfiguration. peerCertificateChain ( )
    返回类型:

    Returns the peer's chain of digital certificates, starting with the peer's immediate certificate and ending with the CA's certificate.

    Peer certificates are checked automatically during the handshake phase. This function is normally used to fetch certificates for display, or for performing connection diagnostics. Certificates contain information about the peer and the certificate issuers, including host name, issuer names, and issuer public keys.

    Because the peer certificate is set during the handshake phase, it is safe to access the peer certificate from a slot connected to the QSslSocket.sslErrors() signal, QNetworkReply.sslErrors() signal, or the QSslSocket.encrypted() 信号。

    If an empty list is returned, it can mean the SSL handshake failed, or it can mean the host you are connected to doesn't have a certificate, or it can mean there is no connection.

    If you want to get only the peer's immediate certificate, use PySide.QtNetwork.QSslConfiguration.peerCertificate() .

    PySide.QtNetwork.QSslConfiguration. peerVerifyDepth ( )
    返回类型: PySide.QtCore.int

    Returns the maximum number of certificates in the peer's certificate chain to be checked during the SSL handshake phase, or 0 (the default) if no maximum depth has been set, indicating that the whole certificate chain should be checked.

    The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.

    PySide.QtNetwork.QSslConfiguration. peerVerifyMode ( )
    返回类型: PySide.QtNetwork.QSslSocket.PeerVerifyMode

    Returns the verify mode. This mode decides whether PySide.QtNetwork.QSslSocket should request a certificate from the peer (i.e., the client requests a certificate from the server, or a server requesting a certificate from the client), and whether it should require that this certificate is valid.

    The default mode is AutoVerifyPeer, which tells PySide.QtNetwork.QSslSocket to use VerifyPeer for clients, QueryPeer for servers.

    PySide.QtNetwork.QSslConfiguration. privateKey ( )
    返回类型: PySide.QtNetwork.QSslKey

    返回 SSL key assigned to this connection or a null key if none has been assigned yet.

    PySide.QtNetwork.QSslConfiguration. protocol ( )
    返回类型: PySide.QtNetwork.QSsl.SslProtocol

    Returns the protocol setting for this SSL configuration.

    PySide.QtNetwork.QSslConfiguration. sessionCipher ( )
    返回类型: PySide.QtNetwork.QSslCipher

    返回套接字的加密 cipher , or a null cipher if the connection isn't encrypted. The socket's cipher for the session is set during the handshake phase. The cipher is used to encrypt and decrypt data transmitted through the socket.

    The SSL infrastructure also provides functions for setting the ordered list of ciphers from which the handshake phase will eventually select the session cipher. This ordered list must be in place before the handshake phase begins.

    PySide.QtNetwork.QSslConfiguration. setCaCertificates ( certificates )
    参数: certificates
    PySide.QtNetwork.QSslConfiguration. setCiphers ( ciphers )
    参数: ciphers
    static PySide.QtNetwork.QSslConfiguration. setDefaultConfiguration ( configuration )
    参数: configuration PySide.QtNetwork.QSslConfiguration

    Sets the default SSL configuration to be used in new SSL connections to be configuration . Existing connections are not affected by this call.

    PySide.QtNetwork.QSslConfiguration. setLocalCertificate ( certificate )
    参数: certificate PySide.QtNetwork.QSslCertificate

    Sets the certificate to be presented to the peer during SSL handshake to be certificate .

    Setting the certificate once the connection has been established has no effect.

    A certificate is the means of identification used in the SSL process. The local certificate is used by the remote end to verify the local user's identity against its list of Certification Authorities. In most cases, such as in HTTP web browsing, only servers identify to the clients, so the client does not send a certificate.

    PySide.QtNetwork.QSslConfiguration. setPeerVerifyDepth ( depth )
    参数: depth PySide.QtCore.int

    Sets the maximum number of certificates in the peer's certificate chain to be checked during the SSL handshake phase, to depth . Setting a depth of 0 means that no maximum depth is set, indicating that the whole certificate chain should be checked.

    The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.

    PySide.QtNetwork.QSslConfiguration. setPeerVerifyMode ( mode )
    参数: mode PySide.QtNetwork.QSslSocket.PeerVerifyMode
    PySide.QtNetwork.QSslConfiguration. setPrivateKey ( key )
    参数: key PySide.QtNetwork.QSslKey

    Sets the connection's private key to key . The private key and the local certificate are used by clients and servers that must prove their identity to SSL peers.

    Both the key and the local certificate are required if you are creating an SSL server socket. If you are creating an SSL client socket, the key and local certificate are required if your client must identify itself to an SSL server.

    PySide.QtNetwork.QSslConfiguration. setProtocol ( protocol )
    参数: protocol PySide.QtNetwork.QSsl.SslProtocol