⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qsslsocket.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
*/QList<QSslCipher> QSslSocket::defaultCiphers(){    return QSslSocketPrivate::defaultCiphers();}/*!    Returns the list of cryptographic ciphers supported by this    system. This list is set by the system's SSL libraries and may    vary from system to system.    \sa defaultCiphers(), ciphers(), setCiphers()*/QList<QSslCipher> QSslSocket::supportedCiphers(){    return QSslSocketPrivate::supportedCiphers();}/*!  Searches all files in the \a path for certificates encoded in the  specified \a format and adds them to this socket's CA certificate  database. \a path can be explicit, or it can contain wildcards in  the format specified by \a syntax. Returns true if one or more  certificates are added to the socket's CA certificate database;  otherwise returns false.  The CA certificate database is used by the socket during the  handshake phase to validate the peer's certificate.  For more precise control, use addCaCertificate().  \sa addCaCertificate(), QSslCertificate::fromPath()*/bool QSslSocket::addCaCertificates(const QString &path, QSsl::EncodingFormat format,                                   QRegExp::PatternSyntax syntax){    Q_D(QSslSocket);    QList<QSslCertificate> certs = QSslCertificate::fromPath(path, format, syntax);    if (certs.isEmpty())        return false;    d->localCaCertificates += certs;    return true;}/*!  Adds the \a certificate to this socket's CA certificate database.  The CA certificate database is used by the socket during the  handshake phase to validate the peer's certificate.  To add multiple certificates, use addCaCertificates().  \sa caCertificates(), setCaCertificates()*/void QSslSocket::addCaCertificate(const QSslCertificate &certificate){    Q_D(QSslSocket);    d->localCaCertificates += certificate;}/*!  Adds the \a certificates to this socket's CA certificate database.  The CA certificate database is used by the socket during the  handshake phase to validate the peer's certificate.  For more precise control, use addCaCertificate().  \sa caCertificates(), addDefaultCaCertificate()*/void QSslSocket::addCaCertificates(const QList<QSslCertificate> &certificates){    Q_D(QSslSocket);    d->localCaCertificates += certificates;}/*!  Sets this socket's CA certificate database to be \a certificates.  The certificate database must be set prior to the SSL handshake.  The CA certificate database is used by the socket during the  handshake phase to validate the peer's certificate.  The CA certificate database can be reset to the current default CA  certificate database by calling this function with the list of CA  certificates returned by defaultCaCertificates().  \sa defaultCaCertificates()*/void QSslSocket::setCaCertificates(const QList<QSslCertificate> &certificates){    Q_D(QSslSocket);    d->useLocalCaCertificatesOnly = true;    d->localCaCertificates = certificates;}/*!  Returns this socket'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 moodified prior to the  handshake with addCaCertificate(), addCACertificates(), and  setCaCertificates().  \sa addCaCertificate(), addCaCertificates(), setCaCertificates()*/QList<QSslCertificate> QSslSocket::caCertificates() const{    Q_D(const QSslSocket);    if (d->useLocalCaCertificatesOnly)        return d->localCaCertificates;    return d->defaultCaCertificates() + d->localCaCertificates;}/*!    Searches all files in the \a path for certificates with the    specified \a encoding and adds them to the default CA certificate    database. \a path can be an explicit file, or it can contain    wildcards in the format specified by \a syntax. Returns true if    any CA certificates are added to the default database.    Each SSL socket's CA certificate database is initialized to the    default CA certificate database.    \sa defaultCaCertificates(), addCaCertificates(), addDefaultCaCertificate()*/bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding,                                          QRegExp::PatternSyntax syntax){    return QSslSocketPrivate::addDefaultCaCertificates(path, encoding, syntax);}/*!    Adds \a certificate to the default CA certificate database.  Each    SSL socket's CA certificate database is initialized to the default    CA certificate database.    \sa defaultCaCertificates(), addCaCertificates()*/void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate){    QSslSocketPrivate::addDefaultCaCertificate(certificate);}/*!    Adds \a certificates to the default CA certificate database.  Each    SSL socket's CA certificate database is initialized to the default    CA certificate database.    \sa defaultCaCertificates(), addCaCertificates()*/void QSslSocket::addDefaultCaCertificates(const QList<QSslCertificate> &certificates){    QSslSocketPrivate::addDefaultCaCertificates(certificates);}/*!    Sets the default CA certificate database to \a certificates. The    default CA certificate database is originally set to your system's    default CA certificate database. If no system default database is    found, Qt will provide its own default database. You can override    the default CA certificate database with your own CA certificate    database using this function.    Each SSL socket's CA certificate database is initialized to the    default CA certificate database.    \sa addDefaultCaCertificate()*/void QSslSocket::setDefaultCaCertificates(const QList<QSslCertificate> &certificates){    QSslSocketPrivate::setDefaultCaCertificates(certificates);}/*!    Returns the current default CA certificate database. This database    is originally set to your system's default CA certificate database.    If no system default database is found, Qt will provide its own    default database. You can override the default CA certificate database    with your own CA certificate database using setDefaultCaCertificates().    Each SSL socket's CA certificate database is initialized to the    default CA certificate database.    \sa caCertificates()*/QList<QSslCertificate> QSslSocket::defaultCaCertificates(){    return QSslSocketPrivate::defaultCaCertificates();}/*!    Returns the system default CA certificate database for your    system. This database is normally found in a standard place for    your system. If it is not found there, Qt will provide its own    default CA certificate database. The CA certificate database    returned by this function is used to initialize the database    returned by defaultCaCertificates(). You can replace that database    with your own with setDefaultCaCertificates().    \sa caCertificates(), defaultCaCertificates(), setDefaultCaCertificates()*/QList<QSslCertificate> QSslSocket::systemCaCertificates(){    QSslSocketPrivate::ensureInitialized();    return QSslSocketPrivate::systemCaCertificates();}/*!    Waits until the socket is connected, or \a msecs milliseconds,    whichever happens first. If the connection has been established,    this function returns true; otherwise it returns false.    \sa QAbstractSocket::waitForConnected()*/bool QSslSocket::waitForConnected(int msecs){    Q_D(QSslSocket);    if (!d->plainSocket)        return false;    bool retVal = d->plainSocket->waitForConnected(msecs);    if (!retVal) {        setSocketState(d->plainSocket->state());        setSocketError(d->plainSocket->error());        setErrorString(d->plainSocket->errorString());    }    return retVal;}/*!    Waits until the socket has completed the SSL handshake and has    emitted encrypted(), or \a msecs milliseconds, whichever comes    first. If encrypted() has been emitted, this function returns    true; otherwise (e.g., the socket is disconnected, or the SSL    handshake fails), false is returned.    The following example waits up to one second for the socket to be    encrypted:    \code        socket->connectToHostEncrypted("imap", 993);        if (socket->waitForEncrypted(1000))            qDebug("Encrypted!");    \endcode    If msecs is -1, this function will not time out.    \sa startClientEncryption(), startServerEncryption(), encrypted(), isEncrypted()*/bool QSslSocket::waitForEncrypted(int msecs){    Q_D(QSslSocket);    if (!d->plainSocket || d->connectionEncrypted)        return false;    if (d->mode == UnencryptedMode && !d->autoStartHandshake)        return false;    QTime stopWatch;    stopWatch.start();    if (d->plainSocket->state() != QAbstractSocket::ConnectedState) {        // Wait until we've entered connected state.        if (!d->plainSocket->waitForConnected(msecs))            return false;    }    while (!d->connectionEncrypted) {        // Start the handshake, if this hasn't been started yet.        if (d->mode == UnencryptedMode)            startClientEncryption();        // Loop, waiting until the connection has been encrypted or an error        // occurs.        if (!d->plainSocket->waitForReadyRead(qBound(0, msecs - stopWatch.elapsed(), msecs)))            return false;    }    return d->connectionEncrypted;}/*!    \reimp*/bool QSslSocket::waitForReadyRead(int msecs){    Q_D(QSslSocket);    if (!d->plainSocket)        return false;    if (d->mode == UnencryptedMode && !d->autoStartHandshake)        return d->plainSocket->waitForReadyRead(msecs);    int oldReadBufferSize = d->readBuffer.size();        QTime stopWatch;    stopWatch.start();    if (!d->connectionEncrypted) {        // Wait until we've entered encrypted mode, or until a failure occurs.        if (!waitForEncrypted(msecs))            return false;    }    while (d->plainSocket->waitForReadyRead(qBound(0, msecs - stopWatch.elapsed(), msecs))) {        if (d->readBuffer.size() != oldReadBufferSize) {            // If the read buffer has grown, readyRead() must have been emitted.            return true;        }    }    return false;}/*!    \reimp*/bool QSslSocket::waitForBytesWritten(int msecs){    Q_D(QSslSocket);    if (!d->plainSocket)        return false;    if (d->mode == UnencryptedMode)        return d->plainSocket->waitForBytesWritten(msecs);    QTime stopWatch;    stopWatch.start();    if (!d->connectionEncrypted) {        // Wait until we've entered encrypted mode, or until a failure occurs.        if (!waitForEncrypted(msecs))            return false;    }    return d->plainSocket->waitForBytesWritten(qBound(0, msecs - stopWatch.elapsed(), msecs));}/*!    Waits until the socket has disconnected or \a msecs milliseconds,    whichever comes first. If the connection has been disconnected,    this function returns true; otherwise it returns false.    \sa QAbstractSocket::waitForDisconnected()*/bool QSslSocket::waitForDisconnected(int msecs){    Q_D(QSslSocket);    // require calling connectToHost() before waitForDisconnected()    if (state() == UnconnectedState) {        qWarning("QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");        return false;    }    if (!d->plainSocket)        return false;    bool retVal = d->plainSocket->waitForDisconnected(msecs);    if (!retVal) {        setSocketState(d->plainSocket->state());        setSocketError(d->plainSocket->error());        setErrorString(d->plainSocket->errorString());    }    return retVal;}/*!    Returns a list of the last SSL errors that occurred. This is the    same list as QSslSocket passes via the sslErrors() signal. If the    connection has been encrypted with no errors, this function will    return an empty list.    \sa connectToHostEncrypted()*/QList<QSslError> QSslSocket::sslErrors() const{    Q_D(const QSslSocket);    return d->sslErrors;}/*!    Returns true if this platform supports SSL; otherwise, returns    false. If the platform doesn't support SSL, the socket will fail    in the connection phase.*/bool QSslSocket::supportsSsl(){    return QSslSocketPrivate::ensureInitialized();}/*!    Starts a delayed SSL handshake for a client connection. This    function can be called when the socket is in the \l ConnectedState    but still in the \l UnencryptedMode. If it is not yet connected,    or if it is already encrypted, this function has no effect.    Clients that implement STARTTLS functionality often make use of    delayed SSL handshakes. Most other clients can avoid calling this    function directly by using connectToHostEncrypted() instead, which    automatically performs the handshake.    \sa connectToHostEncrypted(), startServerEncryption()*/void QSslSocket::startClientEncryption(){    Q_D(QSslSocket);    if (d->mode != UnencryptedMode) {        qWarning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");        return;    }#ifdef QSSLSOCKET_DEBUG    qDebug() << "QSslSocket::startClientEncryption()";#endif    d->mode = SslClientMode;    emit modeChanged(d->mode);    d->startClientEncryption();}/*!    Starts a delayed SSL handshake for a server connection. This    function can be called when the socket is in the \l ConnectedState    but still in \l UnencryptedMode. If it is not connected or it is    already encrypted, the function has no effect.    For server sockets, calling this function is the only way to    initiate the SSL handshake. Most servers will call this function    immediately upon receiving a connection, or as a result of having    received a protocol-specific command to enter SSL mode (e.g, the    server may respond to receiving the string "STARTTLS\r\n" by    calling this function).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -