[QtNetwork module]
该QSslConfiguration类包含一个SSL连接的配置和状态More…
Methods
__init__ (self)
__init__ (self, QSslConfiguration other)
list-of-QSslCertificate caCertificates (self)
list-of-QSslCipher ciphers (self)
bool isNull (self)
QSslCertificate localCertificate (self)
QSslCertificate peerCertificate (self)
list-of-QSslCertificate peerCertificateChain (self)
int peerVerifyDepth (self)
QSslSocket.PeerVerifyMode peerVerifyMode (self)
QSslKey privateKey (self)
QSsl.SslProtocol protocol (self)
QSslCipher sessionCipher (self)
setCaCertificates (self, list-of-QSslCertificate certificates)
setCiphers (self, list-of-QSslCipher ciphers)
setLocalCertificate (self, QSslCertificate certificate)
setPeerVerifyDepth (self, int depth)
setPeerVerifyMode (self, QSslSocket.PeerVerifyMode mode)
setPrivateKey (self, QSslKey key)
setProtocol (self, QSsl.SslProtocol protocol)
setSslOption (self, QSsl.SslOption option, bool on)
bool testSslOption (self, QSsl.SslOption option)
Static Methods
QSslConfiguration defaultConfiguration ()
setDefaultConfiguration (QSslConfiguration configuration)
Special Methods
bool __eq__ (self, QSslConfiguration other)
bool __ne__ (self, QSslConfiguration other)
Detailed Description
该QSslConfiguration类包含一个SSL连接的配置和状态
QSslConfiguration是使用Qt的网络类,转发一个开放的SSL连接信息,并允许应用程序来控制连接的某些功能。
这QSslConfiguration目前支持的设置是:
- 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
这些设置在连接握手过程仅适用。设置它们的连接已经建立后,没有任何效果。
该状态QSslConfiguration支持是:
- The certificate the peer presented during handshake, along with the chain leading to a CA certificate
- The cipher used to encrypt this session
一旦SSL连接启动的状态下才能够获得,但不一定之前,它的完成。某些设置可能,而不需要重新启动它的SSL连接的过程中改变(例如,密码可以被时间改变了) 。
在QSslConfiguration对象的状态不能改变。
QSslConfiguration可以被用于QSslSocket和网络访问的API 。
注意,改变在QSslConfiguration设置是不足以改变在相关的SSL连接的设置。你必须调用修改QSslConfiguration对象setSslConfiguration来实现这个目标。下面的例子演示了如何将协议更改为使用TLSv1在QSslSocket对象:
QSslConfiguration config = sslSocket.sslConfiguration();
config.setProtocol([QSsl](docs_qssl.html).TlsV1);
sslSocket.setSslConfiguration(config);
QSslSocket,QNetworkAccessManager,QSslSocket.sslConfiguration( )QSslSocket.setSslConfiguration( )
Method Documentation
QSslConfiguration.__init__ (self)
构造一个空的SSL配置。此配置不包含有效的设置和状态将是空的。isNull( )将返回True这个构造函数被调用后。
一旦任何setter方法被调用时,isNull( )将返回False 。
QSslConfiguration.__init__ (self, QSslConfiguration other)
副本的配置和状态other。如果other为null,则该对象将是空过。
list-of-QSslCertificate QSslConfiguration.caCertificates (self)
返回此连接的CA证书数据库。握手阶段中的CA证书数据库所使用的插座,以验证对方的证书。它可以与握手之前被修改setCaCertificates() ,或用QSslSocket的addCaCertificate()和addCaCertificates()。
See also setCaCertificates( ) 。
list-of-QSslCipher QSslConfiguration.ciphers (self)
返回此连接的当前密码的加密套件。在握手阶段该列表用于选择一个会话密码。密码返回的列表是按递减优先级进行排序。 (例如,在列表中的第一密码是最优选的密码) 。会话密码将是第一个在也支持对等的列表。
默认情况下,握手阶段可以选择任何由该系统的SSL库支持的加密算法,这可能会有所不同从系统到系统。通过此系统的SSL库支持的密码列表是由返回QSslSocket.supportedCiphers( ) 。你可以通过调用限制用于选择会话密码为这个套接字密码列表setCiphers( )与所支持的加密算法的子集。你可以通过调用恢复使用整套setCiphers( )与返回列表QSslSocket.supportedCiphers( ) 。
See also setCiphers()和QSslSocket.supportedCiphers( ) 。
QSslConfiguration QSslConfiguration.defaultConfiguration ()
[
返回新的SSL连接使用的默认SSL配置。
默认的SSL配置包括:
- 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
](docs_qsslconfiguration.html)
See also QSslSocket.supportedCiphers()和setDefaultConfiguration( ) 。
bool QSslConfiguration.isNull (self)
返回True如果这是一个空QSslConfiguration对象。
A QSslConfiguration对象为null ,如果它已被缺省构造并没有setter方法被调用。
See also setProtocol( )setLocalCertificate( )setPrivateKey( )setCiphers()和setCaCertificates( ) 。
QSslCertificate QSslConfiguration.localCertificate (self)
[
返回在SSL握手过程中要呈现给同行的证书。
](docs_qsslcertificate.html)
See also setLocalCertificate( ) 。
QSslCertificate QSslConfiguration.peerCertificate (self)
[
返回同行的数字证书(即您已连接到主机的直接证明) ,或空凭证,如果对等未分配证书。
对等证书握手阶段中的自动检查,所以这个功能通常用来获取用于显示或连接诊断目的的证书。它包含有关对等的信息,包括它的主机名,证书颁发者,和同行的公钥。
](docs_qsslcertificate.html)
因为对等证书握手阶段中的设置,它是安全的,从连接到一个插槽存取等证书QSslSocket.sslErrors( )信号,QNetworkReply.sslErrors()信号,或QSslSocket.encrypted()信号。
如果证书无效,则返回,它可能意味着SSL握手失败,或者它可能意味着您已连接到主机没有证书,或者它可能意味着没有连接。
如果你想检查对端的完整的证书链,利用peerCertificateChain()来得到一次全部。
See also peerCertificateChain( )QSslSocket.sslErrors( )QSslSocket.ignoreSslErrors( )QNetworkReply.sslErrors()和QNetworkReply.ignoreSslErrors( ) 。
list-of-QSslCertificate QSslConfiguration.peerCertificateChain (self)
返回数字证书,开始与对端的直接证书,并与CA的证书结束的对等的链条。
同行证书握手阶段中的自动检查。此功能通常用于获取证书显示,或用于执行连接诊断。证书包含有关对等和证书发行机构,包括主机名,发行人名称和发行者公开密钥的信息。
因为对等证书握手阶段中的设置,它是安全的,从连接到一个插槽存取等证书QSslSocket.sslErrors( )信号,QNetworkReply.sslErrors()信号,或QSslSocket.encrypted()信号。
如果返回空列表,它可能意味着SSL握手失败,或者它可能意味着您已连接到主机没有证书,或者它可能意味着没有连接。
如果你想只得到了同行的直接证明,使用peerCertificate( ) 。
See also peerCertificate( )QSslSocket.sslErrors( )QSslSocket.ignoreSslErrors( )QNetworkReply.sslErrors()和QNetworkReply.ignoreSslErrors( ) 。
int QSslConfiguration.peerVerifyDepth (self)
返回的证书在同行中的证书链,如果没有最大深度已设置在SSL握手阶段,或0 (默认值)要检查的最大数目,这表明整个证书链应该进行检查。
该证书在发出订单,开始与对端自己的证书,那么它的颁发者的证书,等检查。
See also setPeerVerifyDepth()和peerVerifyMode( ) 。
QSslSocket.PeerVerifyMode QSslConfiguration.peerVerifyMode (self)
返回验证模式。这种模式决定是否QSslSocket应要求对等方的证书(即客户端从服务器请求一个证书,或请求从客户端证书的服务器) ,以及是否应当要求该证书是有效的。
默认模式是AutoVerifyPeer ,它告诉QSslSocket使用VerifyPeer为客户, QueryPeer的服务器。
See also setPeerVerifyMode( ) 。
QSslKey QSslConfiguration.privateKey (self)
返回SSL key分配给该连接或null键,如果没有已分配呢。
See also setPrivateKey()和localCertificate( ) 。
QSsl.SslProtocol QSslConfiguration.protocol (self)
[
返回的协议设置为这个SSL配置。
](docs_qssl.html#SslProtocol-enum)
See also setProtocol( ) 。
QSslCipher QSslConfiguration.sessionCipher (self)
返回套接字的密码cipher或空密码,如果是不加密的连接。套接字的密码在会议期间握手阶段设置。密码是用于加密和解密通过套接字发送的数据。
在SSL基础设施还提供了一些函数来设置密码从中握手阶段将最终选择会话密码的有序列表。这种有序列表必须到位握手阶段开始之前。
See also ciphers( )setCiphers()和QSslSocket.supportedCiphers( ) 。
QSslConfiguration.setCaCertificates (self, list-of-QSslCertificate certificates)
设置此套接字的CA证书数据库是certificates。证书数据库之前必须设置为SSL握手。握手阶段中的CA证书数据库所使用的插座,以验证对方的证书。
See also caCertificates( ) 。
QSslConfiguration.setCiphers (self, list-of-QSslCipher ciphers)
加密的加密套件为这个套接字设置为ciphers,其中必须包含在由supportedCiphers返回列表中的密码的一个子集( ) 。
限制密码套件必须在握手阶段,那里的会话密码被选为前完成。
See also ciphers()和QSslSocket.supportedCiphers( ) 。
QSslConfiguration.setDefaultConfiguration (QSslConfiguration configuration)
设置要使用的新SSL连接是默认的SSL配置configuration。现有的连接不受此调用。
See also QSslSocket.supportedCiphers()和defaultConfiguration( ) 。
QSslConfiguration.setLocalCertificate (self, QSslCertificate certificate)
设置SSL握手过程呈现给对端是证书certificate。
设置证书一旦连接已建立没有任何效果。
证书是在SSL的过程中使用的识别手段。本地证书是由远端验证本地用户的身份对认证机构的名单。在大多数情况下,例如在HTTP网页浏览,只能识别服务器到客户端,所以客户端没有发送证书。
See also localCertificate( ) 。
QSslConfiguration.setPeerVerifyDepth (self, int depth)
设置证书在同行中的证书链在SSL握手阶段进行检查的最大数量,以depth。设置为0的深度表示没有最大深度被设定,表明整个证书链应进行检查。
该证书在发出订单,开始与对端自己的证书,那么它的颁发者的证书,等检查。
See also peerVerifyDepth()和setPeerVerifyMode( ) 。
QSslConfiguration.setPeerVerifyMode (self, QSslSocket.PeerVerifyMode mode)
设置验证模式mode。这种模式决定是否QSslSocket应要求对等方的证书(即客户端从服务器请求一个证书,或请求从客户端证书的服务器) ,以及是否应当要求该证书是有效的。
默认模式是AutoVerifyPeer ,它告诉QSslSocket使用VerifyPeer为客户, QueryPeer的服务器。
See also peerVerifyMode( ) 。
QSslConfiguration.setPrivateKey (self, QSslKey key)
设置连接的私人key至key。私钥和当地certificate所使用的客户端和服务器必须证明自己身份的SSL同行。
密钥和本地证书是必需的,如果你正在创建一个SSL服务器套接字。如果要创建一个SSL客户端套接字,密钥和本地证书是如果你的客户端必须确定自己的SSL服务器所需。
See also privateKey()和setLocalCertificate( ) 。
QSslConfiguration.setProtocol (self, QSsl.SslProtocol protocol)
设置协议设置此配置是protocol。
设置协议一旦连接已经建立没有任何效果。
See also protocol( ) 。
QSslConfiguration.setSslOption (self, QSsl.SslOption option, bool on)
启用或禁用SSL的兼容性选项。
See alsotestSSlOption ( ) 。
bool QSslConfiguration.testSslOption (self, QSsl.SslOption option)
如果启用了指定的SSL兼容性选项,则返回True 。
此功能被引入Qt的4.8 。
See alsotestSSlOption ( ) 。
bool QSslConfiguration.__eq__ (self, QSslConfiguration other)
bool QSslConfiguration.__ne__ (self, QSslConfiguration other)