Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 2139

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsslsocket.cpp -->
  <title>QSslSocket Class | Qt Network 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtnetwork-index.html">Qt Network</a></td><td ><a href="qtnetwork-module.html">C++ Classes</a></td><td >QSslSocket</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtnetwork-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QSslSocket Class</h1>
<!-- $$$QSslSocket-brief -->
<p>The <a href="qsslsocket.html">QSslSocket</a> class provides an SSL encrypted socket for both clients and servers. <a href="#details">More...</a></p>
<!-- @@@QSslSocket -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QSslSocket&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += network</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.3</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qtcpsocket.html">QTcpSocket</a></td></tr></table></div><ul>
<li><a href="qsslsocket-members.html">List of all members, including inherited members</a></li>
<li><a href="qsslsocket-obsolete.html">Obsolete members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#PeerVerifyMode-enum">PeerVerifyMode</a></b> { VerifyNone, QueryPeer, VerifyPeer, AutoVerifyPeer }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#SslMode-enum">SslMode</a></b> { UnencryptedMode, SslClientMode, SslServerMode }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#QSslSocket">QSslSocket</a></b>(QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#dtor.QSslSocket">~QSslSocket</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#abort">abort</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addCaCertificate">addCaCertificate</a></b>(const QSslCertificate &amp;<i>certificate</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addCaCertificates">addCaCertificates</a></b>(const QString &amp;<i>path</i>, QSsl::EncodingFormat <i>format</i> = QSsl::Pem, QRegExp::PatternSyntax <i>syntax</i> = QRegExp::FixedString)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addCaCertificates-1">addCaCertificates</a></b>(const QList&lt;QSslCertificate&gt; &amp;<i>certificates</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a></b>(const QString &amp;<i>hostName</i>, quint16 <i>port</i>, QIODevice::OpenMode <i>mode</i> = ReadWrite, QAbstractSocket::NetworkLayerProtocol <i>protocol</i> = AnyIPProtocol)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#connectToHostEncrypted-1">connectToHostEncrypted</a></b>(const QString &amp;<i>hostName</i>, quint16 <i>port</i>, const QString &amp;<i>sslPeerName</i>, QIODevice::OpenMode <i>mode</i> = ReadWrite, QAbstractSocket::NetworkLayerProtocol <i>protocol</i> = AnyIPProtocol)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#encryptedBytesAvailable">encryptedBytesAvailable</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#encryptedBytesToWrite">encryptedBytesToWrite</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#flush">flush</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#ignoreSslErrors-1">ignoreSslErrors</a></b>(const QList&lt;QSslError&gt; &amp;<i>errors</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#isEncrypted">isEncrypted</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslCertificate </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#localCertificate">localCertificate</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QSslCertificate&gt; </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#localCertificateChain">localCertificateChain</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslSocket::SslMode </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#mode">mode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslCertificate </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerCertificate">peerCertificate</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QSslCertificate&gt; </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerCertificateChain">peerCertificateChain</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerVerifyDepth">peerVerifyDepth</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslSocket::PeerVerifyMode </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerVerifyMode">peerVerifyMode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerVerifyName">peerVerifyName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslKey </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#privateKey">privateKey</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSsl::SslProtocol </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#protocol">protocol</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslCipher </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sessionCipher">sessionCipher</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSsl::SslProtocol </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sessionProtocol">sessionProtocol</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a></b>(const QSslCertificate &amp;<i>certificate</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setLocalCertificate-1">setLocalCertificate</a></b>(const QString &amp;<i>path</i>, QSsl::EncodingFormat <i>format</i> = QSsl::Pem)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setLocalCertificateChain">setLocalCertificateChain</a></b>(const QList&lt;QSslCertificate&gt; &amp;<i>localChain</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPeerVerifyDepth">setPeerVerifyDepth</a></b>(int <i>depth</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPeerVerifyMode">setPeerVerifyMode</a></b>(QSslSocket::PeerVerifyMode <i>mode</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPeerVerifyName">setPeerVerifyName</a></b>(const QString &amp;<i>hostName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPrivateKey">setPrivateKey</a></b>(const QSslKey &amp;<i>key</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPrivateKey-1">setPrivateKey</a></b>(const QString &amp;<i>fileName</i>, QSsl::KeyAlgorithm <i>algorithm</i> = QSsl::Rsa, QSsl::EncodingFormat <i>format</i> = QSsl::Pem, const QByteArray &amp;<i>passPhrase</i> = QByteArray())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setProtocol">setProtocol</a></b>(QSsl::SslProtocol <i>protocol</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setSslConfiguration">setSslConfiguration</a></b>(const QSslConfiguration &amp;<i>configuration</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSslConfiguration </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslConfiguration">sslConfiguration</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QSslError&gt; </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslErrors">sslErrors</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForEncrypted">waitForEncrypted</a></b>(int <i>msecs</i> = 30000)</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#atEnd">atEnd</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#bytesAvailable">bytesAvailable</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#bytesToWrite">bytesToWrite</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#canReadLine">canReadLine</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#close">close</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#resume">resume</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setReadBufferSize">setReadBufferSize</a></b>(qint64 <i>size</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setSocketDescriptor">setSocketDescriptor</a></b>(qintptr <i>socketDescriptor</i>, QAbstractSocket::SocketState <i>state</i> = ConnectedState, QIODevice::OpenMode <i>openMode</i> = ReadWrite) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setSocketOption">setSocketOption</a></b>(QAbstractSocket::SocketOption <i>option</i>, const QVariant &amp;<i>value</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QVariant </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#socketOption">socketOption</a></b>(QAbstractSocket::SocketOption <i>option</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForBytesWritten">waitForBytesWritten</a></b>(int <i>msecs</i> = 30000) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForConnected">waitForConnected</a></b>(int <i>msecs</i> = 30000) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForDisconnected">waitForDisconnected</a></b>(int <i>msecs</i> = 30000) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForReadyRead">waitForReadyRead</a></b>(int <i>msecs</i> = 30000) override</td></tr>
</table></div>
<ul>
<li class="fn">37 public functions inherited from <a href="qabstractsocket.html#public-functions">QAbstractSocket</a></li>
<li class="fn">44 public functions inherited from <a href="../qtcore/qiodevice.html#public-functions">QIODevice</a></li>
<li class="fn">31 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#ignoreSslErrors">ignoreSslErrors</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#startClientEncryption">startClientEncryption</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#startServerEncryption">startServerEncryption</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#encrypted">encrypted</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#encryptedBytesWritten">encryptedBytesWritten</a></b>(qint64 <i>written</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#modeChanged">modeChanged</a></b>(QSslSocket::SslMode <i>mode</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#peerVerifyError">peerVerifyError</a></b>(const QSslError &amp;<i>error</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#preSharedKeyAuthenticationRequired">preSharedKeyAuthenticationRequired</a></b>(QSslPreSharedKeyAuthenticator *<i>authenticator</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslErrors-1">sslErrors</a></b>(const QList&lt;QSslError&gt; &amp;<i>errors</i>)</td></tr>
</table></div>
<ul>
<li class="fn">6 signals inherited from <a href="qabstractsocket.html#signals">QAbstractSocket</a></li>
<li class="fn">6 signals inherited from <a href="../qtcore/qiodevice.html#signals">QIODevice</a></li>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a></b>(const QSslCertificate &amp;<i>certificate</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addDefaultCaCertificates">addDefaultCaCertificates</a></b>(const QString &amp;<i>path</i>, QSsl::EncodingFormat <i>encoding</i> = QSsl::Pem, QRegExp::PatternSyntax <i>syntax</i> = QRegExp::FixedString)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#addDefaultCaCertificates-1">addDefaultCaCertificates</a></b>(const QList&lt;QSslCertificate&gt; &amp;<i>certificates</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> long </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslLibraryBuildVersionNumber">sslLibraryBuildVersionNumber</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslLibraryBuildVersionString">sslLibraryBuildVersionString</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> long </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslLibraryVersionNumber">sslLibraryVersionNumber</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslLibraryVersionString">sslLibraryVersionString</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#supportsSsl">supportsSsl</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">9 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#readData">readData</a></b>(char *<i>data</i>, qint64 <i>maxlen</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#writeData">writeData</a></b>(const char *<i>data</i>, qint64 <i>len</i>) override</td></tr>
</table></div>
<ul>
<li class="fn">10 protected functions inherited from <a href="qabstractsocket.html#protected-functions">QAbstractSocket</a></li>
<li class="fn">5 protected functions inherited from <a href="../qtcore/qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></li>
<li class="fn">10 protected functions inherited from <a href="qabstractsocket.html#protected-functions">QAbstractSocket</a></li>
<li class="fn">5 protected functions inherited from <a href="../qtcore/qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QSslSocket-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qsslsocket.html">QSslSocket</a> class provides an SSL encrypted socket for both clients and servers.</p>
<p><a href="qsslsocket.html">QSslSocket</a> establishes a secure, encrypted TCP connection you can use for transmitting encrypted data. It can operate in both client and server mode, and it supports modern SSL protocols, including SSL 3 and TLS 1.2&#x2e; By default, <a href="qsslsocket.html">QSslSocket</a> uses only SSL protocols which are considered to be secure (<a href="qssl.html#SslProtocol-enum">QSsl::SecureProtocols</a>), but you can change the SSL protocol by calling <a href="qsslsocket.html#setProtocol">setProtocol</a>() as long as you do it before the handshake has started.</p>
<p>SSL encryption operates on top of the existing TCP stream after the socket enters the <a href="qabstractsocket.html#SocketState-enum">ConnectedState</a>. There are two simple ways to establish a secure connection using <a href="qsslsocket.html">QSslSocket</a>: With an immediate SSL handshake, or with a delayed SSL handshake occurring after the connection has been established in unencrypted mode.</p>
<p>The most common way to use <a href="qsslsocket.html">QSslSocket</a> is to construct an object and start a secure connection by calling <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>(). This method starts an immediate SSL handshake once the connection has been established.</p>
<pre class="cpp">

  <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span> <span class="operator">*</span>socket <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span>(<span class="keyword">this</span>);
  connect(socket<span class="operator">,</span> SIGNAL(encrypted())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(ready()));

  socket<span class="operator">-</span><span class="operator">&gt;</span>connectToHostEncrypted(<span class="string">&quot;imap.example.com&quot;</span><span class="operator">,</span> <span class="number">993</span>);

</pre>
<p>As with a plain <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qsslsocket.html">QSslSocket</a> enters the <a href="qabstractsocket.html#SocketState-enum">HostLookupState</a>, <a href="qabstractsocket.html#SocketState-enum">ConnectingState</a>, and finally the <a href="qabstractsocket.html#SocketState-enum">ConnectedState</a>, if the connection is successful. The handshake then starts automatically, and if it succeeds, the <a href="qsslsocket.html#encrypted">encrypted</a>() signal is emitted to indicate the socket has entered the encrypted state and is ready for use.</p>
<p>Note that data can be written to the socket immediately after the return from <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>() (i.e&#x2e;, before the <a href="qsslsocket.html#encrypted">encrypted</a>() signal is emitted). The data is queued in <a href="qsslsocket.html">QSslSocket</a> until after the <a href="qsslsocket.html#encrypted">encrypted</a>() signal is emitted.</p>
<p>An example of using the delayed SSL handshake to secure an existing connection is the case where an SSL server secures an incoming connection. Suppose you create an SSL server class as a subclass of <a href="qtcpserver.html">QTcpServer</a>. You would override <a href="qtcpserver.html#incomingConnection">QTcpServer::incomingConnection</a>() with something like the example below, which first constructs an instance of <a href="qsslsocket.html">QSslSocket</a> and then calls <a href="qsslsocket.html#setSocketDescriptor">setSocketDescriptor</a>() to set the new socket's descriptor to the existing one passed in. It then initiates the SSL handshake by calling <a href="qsslsocket.html#startServerEncryption">startServerEncryption</a>().</p>
<pre class="cpp">

  <span class="type">void</span> SslServer<span class="operator">::</span>incomingConnection(qintptr socketDescriptor)
  {
      <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span> <span class="operator">*</span>serverSocket <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span>;
      <span class="keyword">if</span> (serverSocket<span class="operator">-</span><span class="operator">&gt;</span>setSocketDescriptor(socketDescriptor)) {
          addPendingConnection(serverSocket);
          connect(serverSocket<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span><span class="operator">::</span>encrypted<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>SslServer<span class="operator">::</span>ready);
          serverSocket<span class="operator">-</span><span class="operator">&gt;</span>startServerEncryption();
      } <span class="keyword">else</span> {
          <span class="keyword">delete</span> serverSocket;
      }
  }

</pre>
<p>If an error occurs, <a href="qsslsocket.html">QSslSocket</a> emits the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal. In this case, if no action is taken to ignore the error(s), the connection is dropped. To continue, despite the occurrence of an error, you can call <a href="qsslsocket.html#ignoreSslErrors">ignoreSslErrors</a>(), either from within this slot after the error occurs, or any time after construction of the <a href="qsslsocket.html">QSslSocket</a> and before the connection is attempted. This will allow <a href="qsslsocket.html">QSslSocket</a> to ignore the errors it encounters when establishing the identity of the peer. Ignoring errors during an SSL handshake should be used with caution, since a fundamental characteristic of secure connections is that they should be established with a successful handshake.</p>
<p>Once encrypted, you use <a href="qsslsocket.html">QSslSocket</a> as a regular <a href="qtcpsocket.html">QTcpSocket</a>. When <a href="../qtcore/qiodevice.html#readyRead">readyRead</a>() is emitted, you can call <a href="../qtcore/qiodevice.html#read-1">read</a>(), <a href="qsslsocket.html#canReadLine">canReadLine</a>() and <a href="../qtcore/qiodevice.html#readLine-1">readLine</a>(), or <a href="../qtcore/qiodevice.html#getChar">getChar</a>() to read decrypted data from <a href="qsslsocket.html">QSslSocket</a>'s internal buffer, and you can call <a href="../qtcore/qiodevice.html#write-2">write</a>() or <a href="../qtcore/qiodevice.html#putChar">putChar</a>() to write data back to the peer. <a href="qsslsocket.html">QSslSocket</a> will automatically encrypt the written data for you, and emit <a href="qsslsocket.html#encryptedBytesWritten">encryptedBytesWritten</a>() once the data has been written to the peer.</p>
<p>As a convenience, <a href="qsslsocket.html">QSslSocket</a> supports <a href="qtcpsocket.html">QTcpSocket</a>'s blocking functions <a href="qsslsocket.html#waitForConnected">waitForConnected</a>(), <a href="qsslsocket.html#waitForReadyRead">waitForReadyRead</a>(), <a href="qsslsocket.html#waitForBytesWritten">waitForBytesWritten</a>(), and <a href="qsslsocket.html#waitForDisconnected">waitForDisconnected</a>(). It also provides <a href="qsslsocket.html#waitForEncrypted">waitForEncrypted</a>(), which will block the calling thread until an encrypted connection has been established.</p>
<pre class="cpp">

  <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span> socket;
  socket<span class="operator">.</span>connectToHostEncrypted(<span class="string">&quot;http.example.com&quot;</span><span class="operator">,</span> <span class="number">443</span>);
  <span class="keyword">if</span> (<span class="operator">!</span>socket<span class="operator">.</span>waitForEncrypted()) {
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> socket<span class="operator">.</span>errorString();
      <span class="keyword">return</span> <span class="keyword">false</span>;
  }

  socket<span class="operator">.</span>write(<span class="string">&quot;GET / HTTP/1.0\r\n\r\n&quot;</span>);
  <span class="keyword">while</span> (socket<span class="operator">.</span>waitForReadyRead())
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> socket<span class="operator">.</span>readAll()<span class="operator">.</span>data();

</pre>
<p><a href="qsslsocket.html">QSslSocket</a> provides an extensive, easy-to-use API for handling cryptographic ciphers, private keys, and local, peer, and Certification Authority (CA) certificates. It also provides an API for handling errors that occur during the handshake phase.</p>
<p>The following features can also be customized:</p>
<ul>
<li>The socket's cryptographic cipher suite can be customized before the handshake phase with setCiphers() and setDefaultCiphers().</li>
<li>The socket's local certificate and private key can be customized before the handshake phase with <a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a>() and <a href="qsslsocket.html#setPrivateKey">setPrivateKey</a>().</li>
<li>The CA certificate database can be extended and customized with <a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>(), <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>(), <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>(), <a href="qsslsocket.html#addDefaultCaCertificates">addDefaultCaCertificates</a>(), and <a href="qsslconfiguration.html#defaultConfiguration">QSslConfiguration::defaultConfiguration</a>().setCaCertificates().</li>
</ul>
<p><b>Note: </b>If available, root certificates on Unix (excluding macOS) will be loaded on demand from the standard certificate directories. If you do not want to load root certificates on demand, you need to call either <a href="qsslconfiguration.html#defaultConfiguration">QSslConfiguration::defaultConfiguration</a>().setCaCertificates() before the first SSL handshake is made in your application (for example, via passing QSslSocket::systemCaCertificates() to it), or call <a href="qsslconfiguration.html#defaultConfiguration">QSslConfiguration::defaultConfiguration</a>()::setCaCertificates() on your <a href="qsslsocket.html">QSslSocket</a> instance prior to the SSL handshake.</p><p>For more information about ciphers and certificates, refer to <a href="qsslcipher.html">QSslCipher</a> and <a href="qsslcertificate.html">QSslCertificate</a>.</p>
<p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/">http://www.openssl.org/</a>).</p>
<p><b>Note: </b>Be aware of the difference between the <a href="../qtcore/qiodevice.html#bytesWritten">bytesWritten</a>() signal and the <a href="qsslsocket.html#encryptedBytesWritten">encryptedBytesWritten</a>() signal. For a <a href="qtcpsocket.html">QTcpSocket</a>, <a href="../qtcore/qiodevice.html#bytesWritten">bytesWritten</a>() will get emitted as soon as data has been written to the TCP socket. For a <a href="qsslsocket.html">QSslSocket</a>, <a href="../qtcore/qiodevice.html#bytesWritten">bytesWritten</a>() will get emitted when the data is being encrypted and <a href="qsslsocket.html#encryptedBytesWritten">encryptedBytesWritten</a>() will get emitted as soon as data has been written to the TCP socket.</p></div>
<p><b>See also </b><a href="qsslcertificate.html">QSslCertificate</a>, <a href="qsslcipher.html">QSslCipher</a>, and <a href="qsslerror.html">QSslError</a>.</p>
<!-- @@@QSslSocket -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$PeerVerifyMode$$$VerifyNone$$$QueryPeer$$$VerifyPeer$$$AutoVerifyPeer -->
<h3 class="fn" id="PeerVerifyMode-enum"><a name="PeerVerifyMode-enum"></a>enum QSslSocket::<span class="name">PeerVerifyMode</span></h3>
<p>Describes the peer verification modes for <a href="qsslsocket.html">QSslSocket</a>. The default mode is AutoVerifyPeer, which selects an appropriate mode depending on the socket's QSocket::SslMode.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSslSocket::VerifyNone</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign"><a href="qsslsocket.html">QSslSocket</a> will not request a certificate from the peer. You can set this mode if you are not interested in the identity of the other side of the connection. The connection will still be encrypted, and your socket will still send its local certificate to the peer if it's requested.</td></tr>
<tr><td class="topAlign"><code>QSslSocket::QueryPeer</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign"><a href="qsslsocket.html">QSslSocket</a> will request a certificate from the peer, but does not require this certificate to be valid. This is useful when you want to display peer certificate details to the user without affecting the actual SSL handshake. This mode is the default for servers.</td></tr>
<tr><td class="topAlign"><code>QSslSocket::VerifyPeer</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign"><a href="qsslsocket.html">QSslSocket</a> will request a certificate from the peer during the SSL handshake phase, and requires that this certificate is valid. On failure, <a href="qsslsocket.html">QSslSocket</a> will emit the <a href="qsslsocket.html#sslErrors">QSslSocket::sslErrors</a>() signal. This mode is the default for clients.</td></tr>
<tr><td class="topAlign"><code>QSslSocket::AutoVerifyPeer</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign"><a href="qsslsocket.html">QSslSocket</a> will automatically use QueryPeer for server sockets and VerifyPeer for client sockets.</td></tr>
</table></div>
<p>This enum was introduced or modified in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#peerVerifyMode">QSslSocket::peerVerifyMode</a>().</p>
<!-- @@@PeerVerifyMode -->
<!-- $$$SslMode$$$UnencryptedMode$$$SslClientMode$$$SslServerMode -->
<h3 class="fn" id="SslMode-enum"><a name="SslMode-enum"></a>enum QSslSocket::<span class="name">SslMode</span></h3>
<p>Describes the connection modes available for <a href="qsslsocket.html">QSslSocket</a>.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSslSocket::UnencryptedMode</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The socket is unencrypted. Its behavior is identical to <a href="qtcpsocket.html">QTcpSocket</a>.</td></tr>
<tr><td class="topAlign"><code>QSslSocket::SslClientMode</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The socket is a client-side SSL socket. It is either alreayd encrypted, or it is in the SSL handshake phase (see <a href="qsslsocket.html#isEncrypted">QSslSocket::isEncrypted</a>()).</td></tr>
<tr><td class="topAlign"><code>QSslSocket::SslServerMode</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The socket is a server-side SSL socket. It is either already encrypted, or it is in the SSL handshake phase (see <a href="qsslsocket.html#isEncrypted">QSslSocket::isEncrypted</a>()).</td></tr>
</table></div>
<!-- @@@SslMode -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QSslSocket[overload1]$$$QSslSocketQObject* -->
<h3 class="fn" id="QSslSocket"><a name="QSslSocket"></a>QSslSocket::<span class="name">QSslSocket</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a <a href="qsslsocket.html">QSslSocket</a> object. <i>parent</i> is passed to <a href="../qtcore/qobject.html">QObject</a>'s constructor. The new socket's <a href="qsslcipher.html">cipher</a> suite is set to the one returned by the static method defaultCiphers().</p>
<!-- @@@QSslSocket -->
<!-- $$$~QSslSocket[overload1]$$$~QSslSocket -->
<h3 class="fn" id="dtor.QSslSocket"><a name="dtor.QSslSocket"></a><code>[virtual] </code>QSslSocket::<span class="name">~QSslSocket</span>()</h3>
<p>Destroys the <a href="qsslsocket.html">QSslSocket</a>.</p>
<!-- @@@~QSslSocket -->
<!-- $$$abort[overload1]$$$abort -->
<h3 class="fn" id="abort"><a name="abort"></a><span class="type">void</span> QSslSocket::<span class="name">abort</span>()</h3>
<p>Aborts the current connection and resets the socket. Unlike <a href="qabstractsocket.html#disconnectFromHost">disconnectFromHost</a>(), this function immediately closes the socket, clearing any pending data in the write buffer.</p>
<p><b>See also </b><a href="qabstractsocket.html#disconnectFromHost">disconnectFromHost</a>() and <a href="qsslsocket.html#close">close</a>().</p>
<!-- @@@abort -->
<!-- $$$addCaCertificate[overload1]$$$addCaCertificateconstQSslCertificate& -->
<h3 class="fn" id="addCaCertificate"><a name="addCaCertificate"></a><span class="type">void</span> QSslSocket::<span class="name">addCaCertificate</span>(const <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> &amp;<i>certificate</i>)</h3>
<p>Adds the <i>certificate</i> 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.</p>
<p>To add multiple certificates, use <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>().</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#caCertificates">caCertificates</a>() and <a href="qsslsocket-obsolete.html#setCaCertificates">setCaCertificates</a>().</p>
<!-- @@@addCaCertificate -->
<!-- $$$addCaCertificates[overload1]$$$addCaCertificatesconstQString&QSsl::EncodingFormatQRegExp::PatternSyntax -->
<h3 class="fn" id="addCaCertificates"><a name="addCaCertificates"></a><span class="type">bool</span> QSslSocket::<span class="name">addCaCertificates</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>path</i>, <span class="type"><a href="qssl.html#EncodingFormat-enum">QSsl::EncodingFormat</a></span> <i>format</i> = QSsl::Pem, <span class="type"><a href="../qtcore/qregexp.html#PatternSyntax-enum">QRegExp::PatternSyntax</a></span> <i>syntax</i> = QRegExp::FixedString)</h3>
<p>Searches all files in the <i>path</i> for certificates encoded in the specified <i>format</i> and adds them to this socket's CA certificate database. <i>path</i> must be a file or a pattern matching one or more files, as specified by <i>syntax</i>. Returns <code>true</code> if one or more certificates are added to the socket's CA certificate database; otherwise returns <code>false</code>.</p>
<p>The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.</p>
<p>For more precise control, use <a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>() and <a href="qsslcertificate.html#fromPath">QSslCertificate::fromPath</a>().</p>
<!-- @@@addCaCertificates -->
<!-- $$$addCaCertificates$$$addCaCertificatesconstQList<QSslCertificate>& -->
<h3 class="fn" id="addCaCertificates-1"><a name="addCaCertificates-1"></a><span class="type">void</span> QSslSocket::<span class="name">addCaCertificates</span>(const <span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>&gt; &amp;<i>certificates</i>)</h3>
<p>Adds the <i>certificates</i> 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.</p>
<p>For more precise control, use <a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>().</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#caCertificates">caCertificates</a>() and <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>().</p>
<!-- @@@addCaCertificates -->
<!-- $$$addDefaultCaCertificate[overload1]$$$addDefaultCaCertificateconstQSslCertificate& -->
<h3 class="fn" id="addDefaultCaCertificate"><a name="addDefaultCaCertificate"></a><code>[static] </code><span class="type">void</span> QSslSocket::<span class="name">addDefaultCaCertificate</span>(const <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> &amp;<i>certificate</i>)</h3>
<p>Adds <i>certificate</i> to the default CA certificate database. Each SSL socket's CA certificate database is initialized to the default CA certificate database.</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#defaultCaCertificates">defaultCaCertificates</a>() and <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>().</p>
<!-- @@@addDefaultCaCertificate -->
<!-- $$$addDefaultCaCertificates[overload1]$$$addDefaultCaCertificatesconstQString&QSsl::EncodingFormatQRegExp::PatternSyntax -->
<h3 class="fn" id="addDefaultCaCertificates"><a name="addDefaultCaCertificates"></a><code>[static] </code><span class="type">bool</span> QSslSocket::<span class="name">addDefaultCaCertificates</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>path</i>, <span class="type"><a href="qssl.html#EncodingFormat-enum">QSsl::EncodingFormat</a></span> <i>encoding</i> = QSsl::Pem, <span class="type"><a href="../qtcore/qregexp.html#PatternSyntax-enum">QRegExp::PatternSyntax</a></span> <i>syntax</i> = QRegExp::FixedString)</h3>
<p>Searches all files in the <i>path</i> for certificates with the specified <i>encoding</i> and adds them to the default CA certificate database. <i>path</i> can be an explicit file, or it can contain wildcards in the format specified by <i>syntax</i>. Returns <code>true</code> if any CA certificates are added to the default database.</p>
<p>Each SSL socket's CA certificate database is initialized to the default CA certificate database.</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#defaultCaCertificates">defaultCaCertificates</a>(), <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>(), and <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>().</p>
<!-- @@@addDefaultCaCertificates -->
<!-- $$$addDefaultCaCertificates$$$addDefaultCaCertificatesconstQList<QSslCertificate>& -->
<h3 class="fn" id="addDefaultCaCertificates-1"><a name="addDefaultCaCertificates-1"></a><code>[static] </code><span class="type">void</span> QSslSocket::<span class="name">addDefaultCaCertificates</span>(const <span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>&gt; &amp;<i>certificates</i>)</h3>
<p>Adds <i>certificates</i> to the default CA certificate database. Each SSL socket's CA certificate database is initialized to the default CA certificate database.</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#defaultCaCertificates">defaultCaCertificates</a>() and <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>().</p>
<!-- @@@addDefaultCaCertificates -->
<!-- $$$atEnd[overload1]$$$atEnd -->
<h3 class="fn" id="atEnd"><a name="atEnd"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">atEnd</span>() const</h3>
<p>Reimplemented from <a href="qabstractsocket.html#atEnd">QAbstractSocket::atEnd</a>().</p>
<!-- @@@atEnd -->
<!-- $$$bytesAvailable[overload1]$$$bytesAvailable -->
<h3 class="fn" id="bytesAvailable"><a name="bytesAvailable"></a><code>[override virtual] </code><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">bytesAvailable</span>() const</h3>
<p>Reimplemented from <a href="qabstractsocket.html#bytesAvailable">QAbstractSocket::bytesAvailable</a>().</p>
<p>Returns the number of decrypted bytes that are immediately available for reading.</p>
<!-- @@@bytesAvailable -->
<!-- $$$bytesToWrite[overload1]$$$bytesToWrite -->
<h3 class="fn" id="bytesToWrite"><a name="bytesToWrite"></a><code>[override virtual] </code><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">bytesToWrite</span>() const</h3>
<p>Reimplemented from <a href="qabstractsocket.html#bytesToWrite">QAbstractSocket::bytesToWrite</a>().</p>
<p>Returns the number of unencrypted bytes that are waiting to be encrypted and written to the network.</p>
<!-- @@@bytesToWrite -->
<!-- $$$canReadLine[overload1]$$$canReadLine -->
<h3 class="fn" id="canReadLine"><a name="canReadLine"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">canReadLine</span>() const</h3>
<p>Reimplemented from <a href="qabstractsocket.html#canReadLine">QAbstractSocket::canReadLine</a>().</p>
<p>Returns <code>true</code> if you can read one while line (terminated by a single ASCII '\n' character) of decrypted characters; otherwise, false is returned.</p>
<!-- @@@canReadLine -->
<!-- $$$close[overload1]$$$close -->
<h3 class="fn" id="close"><a name="close"></a><code>[override virtual] </code><span class="type">void</span> QSslSocket::<span class="name">close</span>()</h3>
<p>Reimplemented from <a href="qabstractsocket.html#close">QAbstractSocket::close</a>().</p>
<!-- @@@close -->
<!-- $$$connectToHostEncrypted[overload1]$$$connectToHostEncryptedconstQString&quint16QIODevice::OpenModeQAbstractSocket::NetworkLayerProtocol -->
<h3 class="fn" id="connectToHostEncrypted"><a name="connectToHostEncrypted"></a><span class="type">void</span> QSslSocket::<span class="name">connectToHostEncrypted</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>hostName</i>, <span class="type"><a href="../qtcore/qtglobal.html#quint16-typedef">quint16</a></span> <i>port</i>, <span class="type"><a href="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>mode</i> = ReadWrite, <span class="type"><a href="qabstractsocket.html#NetworkLayerProtocol-enum">QAbstractSocket::NetworkLayerProtocol</a></span> <i>protocol</i> = AnyIPProtocol)</h3>
<p>Starts an encrypted connection to the device <i>hostName</i> on <i>port</i>, using <i>mode</i> as the <a href="../qtcore/qiodevice.html#OpenModeFlag-enum">OpenMode</a>. This is equivalent to calling <a href="qabstractsocket.html#connectToHost">connectToHost</a>() to establish the connection, followed by a call to <a href="qsslsocket.html#startClientEncryption">startClientEncryption</a>(). The <i>protocol</i> parameter can be used to specify which network protocol to use (eg. IPv4 or IPv6).</p>
<p><a href="qsslsocket.html">QSslSocket</a> first enters the <a href="qabstractsocket.html#SocketState-enum">HostLookupState</a>. Then, after entering either the event loop or one of the waitFor...() functions, it enters the <a href="qabstractsocket.html#SocketState-enum">ConnectingState</a>, emits <a href="qabstractsocket.html#connected">connected</a>(), and then initiates the SSL client handshake. At each state change, <a href="qsslsocket.html">QSslSocket</a> emits signal <a href="qabstractsocket.html#stateChanged">stateChanged</a>().</p>
<p>After initiating the SSL client handshake, if the identity of the peer can't be established, signal <a href="qsslsocket.html#sslErrors">sslErrors</a>() is emitted. If you want to ignore the errors and continue connecting, you must call <a href="qsslsocket.html#ignoreSslErrors">ignoreSslErrors</a>(), either from inside a slot function connected to the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal, or prior to entering encrypted mode. If <a href="qsslsocket.html#ignoreSslErrors">ignoreSslErrors</a>() is not called, the connection is dropped, signal <a href="qabstractsocket.html#disconnected">disconnected</a>() is emitted, and <a href="qsslsocket.html">QSslSocket</a> returns to the <a href="qabstractsocket.html#SocketState-enum">UnconnectedState</a>.</p>
<p>If the SSL handshake is successful, <a href="qsslsocket.html">QSslSocket</a> emits <a href="qsslsocket.html#encrypted">encrypted</a>().</p>
<pre class="cpp">

  <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span> socket;
  connect(<span class="operator">&amp;</span>socket<span class="operator">,</span> SIGNAL(encrypted())<span class="operator">,</span> receiver<span class="operator">,</span> SLOT(socketEncrypted()));

  socket<span class="operator">.</span>connectToHostEncrypted(<span class="string">&quot;imap&quot;</span><span class="operator">,</span> <span class="number">993</span>);
  socket<span class="operator">-</span><span class="operator">&gt;</span>write(<span class="string">&quot;1 CAPABILITY\r\n&quot;</span>);

</pre>
<p><b>Note: </b>The example above shows that text can be written to the socket immediately after requesting the encrypted connection, before the <a href="qsslsocket.html#encrypted">encrypted</a>() signal has been emitted. In such cases, the text is queued in the object and written to the socket <i>after</i> the connection is established and the <a href="qsslsocket.html#encrypted">encrypted</a>() signal has been emitted.</p><p>The default for <i>mode</i> is <a href="../qtcore/qiodevice.html#OpenModeFlag-enum">ReadWrite</a>.</p>
<p>If you want to create a <a href="qsslsocket.html">QSslSocket</a> on the server side of a connection, you should instead call <a href="qsslsocket.html#startServerEncryption">startServerEncryption</a>() upon receiving the incoming connection through <a href="qtcpserver.html">QTcpServer</a>.</p>
<p><b>See also </b><a href="qabstractsocket.html#connectToHost">connectToHost</a>(), <a href="qsslsocket.html#startClientEncryption">startClientEncryption</a>(), <a href="qsslsocket.html#waitForConnected">waitForConnected</a>(), and <a href="qsslsocket.html#waitForEncrypted">waitForEncrypted</a>().</p>
<!-- @@@connectToHostEncrypted -->
<!-- $$$connectToHostEncrypted$$$connectToHostEncryptedconstQString&quint16constQString&QIODevice::OpenModeQAbstractSocket::NetworkLayerProtocol -->
<h3 class="fn" id="connectToHostEncrypted-1"><a name="connectToHostEncrypted-1"></a><span class="type">void</span> QSslSocket::<span class="name">connectToHostEncrypted</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>hostName</i>, <span class="type"><a href="../qtcore/qtglobal.html#quint16-typedef">quint16</a></span> <i>port</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>sslPeerName</i>, <span class="type"><a href="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>mode</i> = ReadWrite, <span class="type"><a href="qabstractsocket.html#NetworkLayerProtocol-enum">QAbstractSocket::NetworkLayerProtocol</a></span> <i>protocol</i> = AnyIPProtocol)</h3>
<p>This is an overloaded function.</p>
<p>In addition to the original behaviour of <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>, this overloaded method enables the usage of a different hostname (<i>sslPeerName</i>) for the certificate validation instead of the one used for the TCP connection (<i>hostName</i>).</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>().</p>
<!-- @@@connectToHostEncrypted -->
<!-- $$$encrypted[overload1]$$$encrypted -->
<h3 class="fn" id="encrypted"><a name="encrypted"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">encrypted</span>()</h3>
<p>This signal is emitted when <a href="qsslsocket.html">QSslSocket</a> enters encrypted mode. After this signal has been emitted, <a href="qsslsocket.html#isEncrypted">QSslSocket::isEncrypted</a>() will return true, and all further transmissions on the socket will be encrypted.</p>
<p><b>See also </b><a href="qsslsocket.html#connectToHostEncrypted">QSslSocket::connectToHostEncrypted</a>() and <a href="qsslsocket.html#isEncrypted">QSslSocket::isEncrypted</a>().</p>
<!-- @@@encrypted -->
<!-- $$$encryptedBytesAvailable[overload1]$$$encryptedBytesAvailable -->
<h3 class="fn" id="encryptedBytesAvailable"><a name="encryptedBytesAvailable"></a><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">encryptedBytesAvailable</span>() const</h3>
<p>Returns the number of encrypted bytes that are awaiting decryption. Normally, this function will return 0 because <a href="qsslsocket.html">QSslSocket</a> decrypts its incoming data as soon as it can.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@encryptedBytesAvailable -->
<!-- $$$encryptedBytesToWrite[overload1]$$$encryptedBytesToWrite -->
<h3 class="fn" id="encryptedBytesToWrite"><a name="encryptedBytesToWrite"></a><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">encryptedBytesToWrite</span>() const</h3>
<p>Returns the number of encrypted bytes that are waiting to be written to the network.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@encryptedBytesToWrite -->
<!-- $$$encryptedBytesWritten[overload1]$$$encryptedBytesWrittenqint64 -->
<h3 class="fn" id="encryptedBytesWritten"><a name="encryptedBytesWritten"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">encryptedBytesWritten</span>(<span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> <i>written</i>)</h3>
<p>This signal is emitted when <a href="qsslsocket.html">QSslSocket</a> writes its encrypted data to the network. The <i>written</i> parameter contains the number of bytes that were successfully written.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="../qtcore/qiodevice.html#bytesWritten">QIODevice::bytesWritten</a>().</p>
<!-- @@@encryptedBytesWritten -->
<!-- $$$flush[overload1]$$$flush -->
<h3 class="fn" id="flush"><a name="flush"></a><span class="type">bool</span> QSslSocket::<span class="name">flush</span>()</h3>
<p>This function writes as much as possible from the internal write buffer to the underlying network socket, without blocking. If any data was written, this function returns <code>true</code>; otherwise false is returned.</p>
<p>Call this function if you need <a href="qsslsocket.html">QSslSocket</a> to start sending buffered data immediately. The number of bytes successfully written depends on the operating system. In most cases, you do not need to call this function, because <a href="qabstractsocket.html">QAbstractSocket</a> will start sending data automatically once control goes back to the event loop. In the absence of an event loop, call <a href="qsslsocket.html#waitForBytesWritten">waitForBytesWritten</a>() instead.</p>
<p><b>See also </b><a href="../qtcore/qiodevice.html#write-2">write</a>() and <a href="qsslsocket.html#waitForBytesWritten">waitForBytesWritten</a>().</p>
<!-- @@@flush -->
<!-- $$$ignoreSslErrors[overload1]$$$ignoreSslErrors -->
<h3 class="fn" id="ignoreSslErrors"><a name="ignoreSslErrors"></a><code>[slot] </code><span class="type">void</span> QSslSocket::<span class="name">ignoreSslErrors</span>()</h3>
<p>This slot tells <a href="qsslsocket.html">QSslSocket</a> to ignore errors during <a href="qsslsocket.html">QSslSocket</a>'s handshake phase and continue connecting. If you want to continue with the connection even if errors occur during the handshake phase, then you must call this slot, either from a slot connected to <a href="qsslsocket.html#sslErrors">sslErrors</a>(), or before the handshake phase. If you don't call this slot, either in response to errors or before the handshake, the connection will be dropped after the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal has been emitted.</p>
<p>If there are no errors during the SSL handshake phase (i.e&#x2e;, the identity of the peer is established with no problems), <a href="qsslsocket.html">QSslSocket</a> will not emit the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal, and it is unnecessary to call this function.</p>
<p><b>Warning:</b> Be sure to always let the user inspect the errors reported by the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal, and only call this method upon confirmation from the user that proceeding is ok. If there are unexpected errors, the connection should be aborted. Calling this method without inspecting the actual errors will most likely pose a security risk for your application. Use it with great care!</p>
<p><b>See also </b><a href="qsslsocket.html#sslErrors">sslErrors</a>().</p>
<!-- @@@ignoreSslErrors -->
<!-- $$$ignoreSslErrors$$$ignoreSslErrorsconstQList<QSslError>& -->
<h3 class="fn" id="ignoreSslErrors-1"><a name="ignoreSslErrors-1"></a><span class="type">void</span> QSslSocket::<span class="name">ignoreSslErrors</span>(const <span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslerror.html">QSslError</a></span>&gt; &amp;<i>errors</i>)</h3>
<p>This is an overloaded function.</p>
<p>This method tells <a href="qsslsocket.html">QSslSocket</a> to ignore only the errors given in <i>errors</i>.</p>
<p><b>Note: </b>Because most SSL errors are associated with a certificate, for most of them you must set the expected certificate this SSL error is related to. If, for instance, you want to connect to a server that uses a self-signed certificate, consider the following snippet:</p><pre class="cpp">

  <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span><span class="operator">&gt;</span> cert <span class="operator">=</span> <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span><span class="operator">::</span>fromPath(QLatin1String(<span class="string">&quot;server-certificate.pem&quot;</span>));
  <span class="type"><a href="qsslerror.html">QSslError</a></span> error(<span class="type"><a href="qsslerror.html">QSslError</a></span><span class="operator">::</span>SelfSignedCertificate<span class="operator">,</span> cert<span class="operator">.</span>at(<span class="number">0</span>));
  <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qsslerror.html">QSslError</a></span><span class="operator">&gt;</span> expectedSslErrors;
  expectedSslErrors<span class="operator">.</span>append(error);

  <span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span> socket;
  socket<span class="operator">.</span>ignoreSslErrors(expectedSslErrors);
  socket<span class="operator">.</span>connectToHostEncrypted(<span class="string">&quot;server.tld&quot;</span><span class="operator">,</span> <span class="number">443</span>);

</pre>
<p>Multiple calls to this function will replace the list of errors that were passed in previous calls. You can clear the list of errors you want to ignore by calling this function with an empty list.</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qsslsocket.html#sslErrors">sslErrors</a>().</p>
<!-- @@@ignoreSslErrors -->
<!-- $$$isEncrypted[overload1]$$$isEncrypted -->
<h3 class="fn" id="isEncrypted"><a name="isEncrypted"></a><span class="type">bool</span> QSslSocket::<span class="name">isEncrypted</span>() const</h3>
<p>Returns <code>true</code> if the socket is encrypted; otherwise, false is returned.</p>
<p>An encrypted socket encrypts all data that is written by calling <a href="../qtcore/qiodevice.html#write-2">write</a>() or <a href="../qtcore/qiodevice.html#putChar">putChar</a>() before the data is written to the network, and decrypts all incoming data as the data is received from the network, before you call <a href="../qtcore/qiodevice.html#read-1">read</a>(), <a href="../qtcore/qiodevice.html#readLine-1">readLine</a>() or <a href="../qtcore/qiodevice.html#getChar">getChar</a>().</p>
<p><a href="qsslsocket.html">QSslSocket</a> emits <a href="qsslsocket.html#encrypted">encrypted</a>() when it enters encrypted mode.</p>
<p>You can call <a href="qsslsocket.html#sessionCipher">sessionCipher</a>() to find which cryptographic cipher is used to encrypt and decrypt your data.</p>
<p><b>See also </b><a href="qsslsocket.html#mode">mode</a>().</p>
<!-- @@@isEncrypted -->
<!-- $$$localCertificate[overload1]$$$localCertificate -->
<h3 class="fn" id="localCertificate"><a name="localCertificate"></a><span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> QSslSocket::<span class="name">localCertificate</span>() const</h3>
<p>Returns the socket's local <a href="qsslcertificate.html">certificate</a>, or an empty certificate if no local certificate has been assigned.</p>
<p><b>See also </b><a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a>() and <a href="qsslsocket.html#privateKey">privateKey</a>().</p>
<!-- @@@localCertificate -->
<!-- $$$localCertificateChain[overload1]$$$localCertificateChain -->
<h3 class="fn" id="localCertificateChain"><a name="localCertificateChain"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>&gt; QSslSocket::<span class="name">localCertificateChain</span>() const</h3>
<p>Returns the socket's local <a href="qsslcertificate.html">certificate</a> chain, or an empty list if no local certificates have been assigned.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qsslsocket.html#setLocalCertificateChain">setLocalCertificateChain</a>().</p>
<!-- @@@localCertificateChain -->
<!-- $$$mode[overload1]$$$mode -->
<h3 class="fn" id="mode"><a name="mode"></a><span class="type"><a href="qsslsocket.html#SslMode-enum">QSslSocket::SslMode</a></span> QSslSocket::<span class="name">mode</span>() const</h3>
<p>Returns the current mode for the socket; either <a href="qsslsocket.html#SslMode-enum">UnencryptedMode</a>, where <a href="qsslsocket.html">QSslSocket</a> behaves identially to <a href="qtcpsocket.html">QTcpSocket</a>, or one of <a href="qsslsocket.html#SslMode-enum">SslClientMode</a> or <a href="qsslsocket.html#SslMode-enum">SslServerMode</a>, where the client is either negotiating or in encrypted mode.</p>
<p>When the mode changes, <a href="qsslsocket.html">QSslSocket</a> emits <a href="qsslsocket.html#modeChanged">modeChanged</a>()</p>
<p><b>See also </b><a href="qsslsocket.html#SslMode-enum">SslMode</a>.</p>
<!-- @@@mode -->
<!-- $$$modeChanged[overload1]$$$modeChangedQSslSocket::SslMode -->
<h3 class="fn" id="modeChanged"><a name="modeChanged"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">modeChanged</span>(<span class="type"><a href="qsslsocket.html#SslMode-enum">QSslSocket::SslMode</a></span> <i>mode</i>)</h3>
<p>This signal is emitted when <a href="qsslsocket.html">QSslSocket</a> changes from <a href="qsslsocket.html#SslMode-enum">QSslSocket::UnencryptedMode</a> to either <a href="qsslsocket.html#SslMode-enum">QSslSocket::SslClientMode</a> or <a href="qsslsocket.html#SslMode-enum">QSslSocket::SslServerMode</a>. <i>mode</i> is the new mode.</p>
<p><b>See also </b><a href="qsslsocket.html#mode">QSslSocket::mode</a>().</p>
<!-- @@@modeChanged -->
<!-- $$$peerCertificate[overload1]$$$peerCertificate -->
<h3 class="fn" id="peerCertificate"><a name="peerCertificate"></a><span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> QSslSocket::<span class="name">peerCertificate</span>() const</h3>
<p>Returns the peer's digital certificate (i.e&#x2e;, the immediate certificate of the host you are connected to), or a null certificate, if the peer has not assigned a certificate.</p>
<p>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.</p>
<p>Because the peer certificate is set during the handshake phase, it is safe to access the peer certificate from a slot connected to the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal or the <a href="qsslsocket.html#encrypted">encrypted</a>() signal.</p>
<p>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.</p>
<p>If you want to check the peer's complete chain of certificates, use <a href="qsslsocket.html#peerCertificateChain">peerCertificateChain</a>() to get them all at once.</p>
<p><b>See also </b><a href="qsslsocket.html#peerCertificateChain">peerCertificateChain</a>().</p>
<!-- @@@peerCertificate -->
<!-- $$$peerCertificateChain[overload1]$$$peerCertificateChain -->
<h3 class="fn" id="peerCertificateChain"><a name="peerCertificateChain"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>&gt; QSslSocket::<span class="name">peerCertificateChain</span>() const</h3>
<p>Returns the peer's chain of digital certificates, or an empty list of certificates.</p>
<p>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.</p>
<p>The peer certificates are set in <a href="qsslsocket.html">QSslSocket</a> during the handshake phase, so it is safe to call this function from a slot connected to the <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal or the <a href="qsslsocket.html#encrypted">encrypted</a>() signal.</p>
<p>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.</p>
<p>If you want to get only the peer's immediate certificate, use <a href="qsslsocket.html#peerCertificate">peerCertificate</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#peerCertificate">peerCertificate</a>().</p>
<!-- @@@peerCertificateChain -->
<!-- $$$peerVerifyDepth[overload1]$$$peerVerifyDepth -->
<h3 class="fn" id="peerVerifyDepth"><a name="peerVerifyDepth"></a><span class="type">int</span> QSslSocket::<span class="name">peerVerifyDepth</span>() const</h3>
<p>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.</p>
<p>The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#setPeerVerifyDepth">setPeerVerifyDepth</a>() and <a href="qsslsocket.html#peerVerifyMode">peerVerifyMode</a>().</p>
<!-- @@@peerVerifyDepth -->
<!-- $$$peerVerifyError[overload1]$$$peerVerifyErrorconstQSslError& -->
<h3 class="fn" id="peerVerifyError"><a name="peerVerifyError"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">peerVerifyError</span>(const <span class="type"><a href="qsslerror.html">QSslError</a></span> &amp;<i>error</i>)</h3>
<p><a href="qsslsocket.html">QSslSocket</a> can emit this signal several times during the SSL handshake, before encryption has been established, to indicate that an error has occurred while establishing the identity of the peer. The <i>error</i> is usually an indication that <a href="qsslsocket.html">QSslSocket</a> is unable to securely identify the peer.</p>
<p>This signal provides you with an early indication when something's wrong. By connecting to this signal, you can manually choose to tear down the connection from inside the connected slot before the handshake has completed. If no action is taken, <a href="qsslsocket.html">QSslSocket</a> will proceed to emitting <a href="qsslsocket.html#sslErrors">QSslSocket::sslErrors</a>().</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#sslErrors">sslErrors</a>().</p>
<!-- @@@peerVerifyError -->
<!-- $$$peerVerifyMode[overload1]$$$peerVerifyMode -->
<h3 class="fn" id="peerVerifyMode"><a name="peerVerifyMode"></a><span class="type"><a href="qsslsocket.html#PeerVerifyMode-enum">QSslSocket::PeerVerifyMode</a></span> QSslSocket::<span class="name">peerVerifyMode</span>() const</h3>
<p>Returns the socket's verify mode. This mode decides whether <a href="qsslsocket.html">QSslSocket</a> should request a certificate from the peer (i.e&#x2e;, 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.</p>
<p>The default mode is <a href="qsslsocket.html#PeerVerifyMode-enum">AutoVerifyPeer</a>, which tells <a href="qsslsocket.html">QSslSocket</a> to use <a href="qsslsocket.html#PeerVerifyMode-enum">VerifyPeer</a> for clients and <a href="qsslsocket.html#PeerVerifyMode-enum">QueryPeer</a> for servers.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#setPeerVerifyMode">setPeerVerifyMode</a>(), <a href="qsslsocket.html#peerVerifyDepth">peerVerifyDepth</a>(), and <a href="qsslsocket.html#mode">mode</a>().</p>
<!-- @@@peerVerifyMode -->
<!-- $$$peerVerifyName[overload1]$$$peerVerifyName -->
<h3 class="fn" id="peerVerifyName"><a name="peerVerifyName"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSslSocket::<span class="name">peerVerifyName</span>() const</h3>
<p>Returns the different hostname for the certificate validation, as set by <a href="qsslsocket.html#setPeerVerifyName">setPeerVerifyName</a> or by <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qsslsocket.html#setPeerVerifyName">setPeerVerifyName</a>() and <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>().</p>
<!-- @@@peerVerifyName -->
<!-- $$$preSharedKeyAuthenticationRequired[overload1]$$$preSharedKeyAuthenticationRequiredQSslPreSharedKeyAuthenticator* -->
<h3 class="fn" id="preSharedKeyAuthenticationRequired"><a name="preSharedKeyAuthenticationRequired"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">preSharedKeyAuthenticationRequired</span>(<span class="type"><a href="qsslpresharedkeyauthenticator.html">QSslPreSharedKeyAuthenticator</a></span> *<i>authenticator</i>)</h3>
<p><a href="qsslsocket.html">QSslSocket</a> emits this signal when it negotiates a PSK ciphersuite, and therefore a PSK authentication is then required.</p>
<p>When using PSK, the client must send to the server a valid identity and a valid pre shared key, in order for the SSL handshake to continue. Applications can provide this information in a slot connected to this signal, by filling in the passed <i>authenticator</i> object according to their needs.</p>
<p><b>Note: </b>Ignoring this signal, or failing to provide the required credentials, will cause the handshake to fail, and therefore the connection to be aborted.</p><p><b>Note: </b>The <i>authenticator</i> object is owned by the socket and must not be deleted by the application.</p><p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qsslpresharedkeyauthenticator.html">QSslPreSharedKeyAuthenticator</a>.</p>
<!-- @@@preSharedKeyAuthenticationRequired -->
<!-- $$$privateKey[overload1]$$$privateKey -->
<h3 class="fn" id="privateKey"><a name="privateKey"></a><span class="type"><a href="qsslkey.html">QSslKey</a></span> QSslSocket::<span class="name">privateKey</span>() const</h3>
<p>Returns this socket's private key.</p>
<p><b>See also </b><a href="qsslsocket.html#setPrivateKey">setPrivateKey</a>() and <a href="qsslsocket.html#localCertificate">localCertificate</a>().</p>
<!-- @@@privateKey -->
<!-- $$$protocol[overload1]$$$protocol -->
<h3 class="fn" id="protocol"><a name="protocol"></a><span class="type"><a href="qssl.html#SslProtocol-enum">QSsl::SslProtocol</a></span> QSslSocket::<span class="name">protocol</span>() const</h3>
<p>Returns the socket's SSL protocol. By default, <a href="qssl.html#SslProtocol-enum">QSsl::SecureProtocols</a> is used.</p>
<p><b>See also </b><a href="qsslsocket.html#setProtocol">setProtocol</a>().</p>
<!-- @@@protocol -->
<!-- $$$readData[overload1]$$$readDatachar*qint64 -->
<h3 class="fn" id="readData"><a name="readData"></a><code>[override virtual protected] </code><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">readData</span>(<span class="type">char</span> *<i>data</i>, <span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> <i>maxlen</i>)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#readData">QAbstractSocket::readData</a>().</p>
<!-- @@@readData -->
<!-- $$$resume[overload1]$$$resume -->
<h3 class="fn" id="resume"><a name="resume"></a><code>[override virtual] </code><span class="type">void</span> QSslSocket::<span class="name">resume</span>()</h3>
<p>Reimplemented from <a href="qabstractsocket.html#resume">QAbstractSocket::resume</a>().</p>
<p>Continues data transfer on the socket after it has been paused. If &quot;<a href="qabstractsocket.html#setPauseMode">setPauseMode</a>(<a href="qabstractsocket.html#PauseMode-enum">QAbstractSocket::PauseOnSslErrors</a>);&quot; has been called on this socket and a <a href="qsslsocket.html#sslErrors">sslErrors</a>() signal is received, calling this method is necessary for the socket to continue.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qabstractsocket.html#pauseMode">QAbstractSocket::pauseMode</a>() and <a href="qabstractsocket.html#setPauseMode">QAbstractSocket::setPauseMode</a>().</p>
<!-- @@@resume -->
<!-- $$$sessionCipher[overload1]$$$sessionCipher -->
<h3 class="fn" id="sessionCipher"><a name="sessionCipher"></a><span class="type"><a href="qsslcipher.html">QSslCipher</a></span> QSslSocket::<span class="name">sessionCipher</span>() const</h3>
<p>Returns the socket's cryptographic <a href="qsslcipher.html">cipher</a>, 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.</p>
<p><a href="qsslsocket.html">QSslSocket</a> 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.</p>
<p><b>See also </b><a href="qsslsocket-obsolete.html#ciphers">ciphers</a>(), <a href="qsslsocket-obsolete.html#setCiphers">setCiphers</a>(), <a href="qsslsocket-obsolete.html#setDefaultCiphers">setDefaultCiphers</a>(), <a href="qsslsocket-obsolete.html#defaultCiphers">defaultCiphers</a>(), and <a href="qsslsocket-obsolete.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@sessionCipher -->
<!-- $$$sessionProtocol[overload1]$$$sessionProtocol -->
<h3 class="fn" id="sessionProtocol"><a name="sessionProtocol"></a><span class="type"><a href="qssl.html#SslProtocol-enum">QSsl::SslProtocol</a></span> QSslSocket::<span class="name">sessionProtocol</span>() const</h3>
<p>Returns the socket's SSL/TLS protocol or UnknownProtocol if the connection isn't encrypted. The socket's protocol for the session is set during the handshake phase.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qsslsocket.html#protocol">protocol</a>() and <a href="qsslsocket.html#setProtocol">setProtocol</a>().</p>
<!-- @@@sessionProtocol -->
<!-- $$$setLocalCertificate[overload1]$$$setLocalCertificateconstQSslCertificate& -->
<h3 class="fn" id="setLocalCertificate"><a name="setLocalCertificate"></a><span class="type">void</span> QSslSocket::<span class="name">setLocalCertificate</span>(const <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> &amp;<i>certificate</i>)</h3>
<p>Sets the socket's local certificate to <i>certificate</i>. The local certificate is necessary if you need to confirm your identity to the peer. It is used together with the private key; if you set the local certificate, you must also set the private key.</p>
<p>The local certificate and private key are always necessary for server sockets, but are also rarely used by client sockets if the server requires the client to authenticate.</p>
<p><b>Note: </b>Secure Transport SSL backend on macOS may update the default keychain (the default is probably your login keychain) by importing your local certificates and keys. This can also result in system dialogs showing up and asking for permission when your application is using these private keys. If such behavior is undesired, set the QT_SSL_USE_TEMPORARY_KEYCHAIN environment variable to a non-zero value; this will prompt <a href="qsslsocket.html">QSslSocket</a> to use its own temporary keychain.</p><p><b>See also </b><a href="qsslsocket.html#localCertificate">localCertificate</a>() and <a href="qsslsocket.html#setPrivateKey">setPrivateKey</a>().</p>
<!-- @@@setLocalCertificate -->
<!-- $$$setLocalCertificate$$$setLocalCertificateconstQString&QSsl::EncodingFormat -->
<h3 class="fn" id="setLocalCertificate-1"><a name="setLocalCertificate-1"></a><span class="type">void</span> QSslSocket::<span class="name">setLocalCertificate</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>path</i>, <span class="type"><a href="qssl.html#EncodingFormat-enum">QSsl::EncodingFormat</a></span> <i>format</i> = QSsl::Pem)</h3>
<p>This is an overloaded function.</p>
<p>Sets the socket's local <a href="qsslcertificate.html">certificate</a> to the first one found in file <i>path</i>, which is parsed according to the specified <i>format</i>.</p>
<!-- @@@setLocalCertificate -->
<!-- $$$setLocalCertificateChain[overload1]$$$setLocalCertificateChainconstQList<QSslCertificate>& -->
<h3 class="fn" id="setLocalCertificateChain"><a name="setLocalCertificateChain"></a><span class="type">void</span> QSslSocket::<span class="name">setLocalCertificateChain</span>(const <span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>&gt; &amp;<i>localChain</i>)</h3>
<p>Sets the certificate chain to be presented to the peer during the SSL handshake to be <i>localChain</i>.</p>
<p>This function was introduced in  Qt 5.1.</p>
<p><b>See also </b><a href="qsslsocket.html#localCertificateChain">localCertificateChain</a>() and <a href="qsslconfiguration.html#setLocalCertificateChain">QSslConfiguration::setLocalCertificateChain</a>().</p>
<!-- @@@setLocalCertificateChain -->
<!-- $$$setPeerVerifyDepth[overload1]$$$setPeerVerifyDepthint -->
<h3 class="fn" id="setPeerVerifyDepth"><a name="setPeerVerifyDepth"></a><span class="type">void</span> QSslSocket::<span class="name">setPeerVerifyDepth</span>(<span class="type">int</span> <i>depth</i>)</h3>
<p>Sets the maximum number of certificates in the peer's certificate chain to be checked during the SSL handshake phase, to <i>depth</i>. Setting a depth of 0 means that no maximum depth is set, indicating that the whole certificate chain should be checked.</p>
<p>The certificates are checked in issuing order, starting with the peer's own certificate, then its issuer's certificate, and so on.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#peerVerifyDepth">peerVerifyDepth</a>() and <a href="qsslsocket.html#setPeerVerifyMode">setPeerVerifyMode</a>().</p>
<!-- @@@setPeerVerifyDepth -->
<!-- $$$setPeerVerifyMode[overload1]$$$setPeerVerifyModeQSslSocket::PeerVerifyMode -->
<h3 class="fn" id="setPeerVerifyMode"><a name="setPeerVerifyMode"></a><span class="type">void</span> QSslSocket::<span class="name">setPeerVerifyMode</span>(<span class="type"><a href="qsslsocket.html#PeerVerifyMode-enum">QSslSocket::PeerVerifyMode</a></span> <i>mode</i>)</h3>
<p>Sets the socket's verify mode to <i>mode</i>. This mode decides whether <a href="qsslsocket.html">QSslSocket</a> should request a certificate from the peer (i.e&#x2e;, 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.</p>
<p>The default mode is <a href="qsslsocket.html#PeerVerifyMode-enum">AutoVerifyPeer</a>, which tells <a href="qsslsocket.html">QSslSocket</a> to use <a href="qsslsocket.html#PeerVerifyMode-enum">VerifyPeer</a> for clients and <a href="qsslsocket.html#PeerVerifyMode-enum">QueryPeer</a> for servers.</p>
<p>Setting this mode after encryption has started has no effect on the current connection.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#peerVerifyMode">peerVerifyMode</a>(), <a href="qsslsocket.html#setPeerVerifyDepth">setPeerVerifyDepth</a>(), and <a href="qsslsocket.html#mode">mode</a>().</p>
<!-- @@@setPeerVerifyMode -->
<!-- $$$setPeerVerifyName[overload1]$$$setPeerVerifyNameconstQString& -->
<h3 class="fn" id="setPeerVerifyName"><a name="setPeerVerifyName"></a><span class="type">void</span> QSslSocket::<span class="name">setPeerVerifyName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>hostName</i>)</h3>
<p>Sets a different host name, given by <i>hostName</i>, for the certificate validation instead of the one used for the TCP connection.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qsslsocket.html#peerVerifyName">peerVerifyName</a>() and <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>().</p>
<!-- @@@setPeerVerifyName -->
<!-- $$$setPrivateKey[overload1]$$$setPrivateKeyconstQSslKey& -->
<h3 class="fn" id="setPrivateKey"><a name="setPrivateKey"></a><span class="type">void</span> QSslSocket::<span class="name">setPrivateKey</span>(const <span class="type"><a href="qsslkey.html">QSslKey</a></span> &amp;<i>key</i>)</h3>
<p>Sets the socket's private <a href="qsslkey.html">key</a> to <i>key</i>. The private key and the local <a href="qsslcertificate.html">certificate</a> are used by clients and servers that must prove their identity to SSL peers.</p>
<p>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.</p>
<p><b>See also </b><a href="qsslsocket.html#privateKey">privateKey</a>() and <a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a>().</p>
<!-- @@@setPrivateKey -->
<!-- $$$setPrivateKey$$$setPrivateKeyconstQString&QSsl::KeyAlgorithmQSsl::EncodingFormatconstQByteArray& -->
<h3 class="fn" id="setPrivateKey-1"><a name="setPrivateKey-1"></a><span class="type">void</span> QSslSocket::<span class="name">setPrivateKey</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>, <span class="type"><a href="qssl.html#KeyAlgorithm-enum">QSsl::KeyAlgorithm</a></span> <i>algorithm</i> = QSsl::Rsa, <span class="type"><a href="qssl.html#EncodingFormat-enum">QSsl::EncodingFormat</a></span> <i>format</i> = QSsl::Pem, const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>passPhrase</i> = QByteArray())</h3>
<p>This is an overloaded function.</p>
<p>Reads the string in file <i>fileName</i> and decodes it using a specified <i>algorithm</i> and encoding <i>format</i> to construct an <a href="qsslkey.html">SSL key</a>. If the encoded key is encrypted, <i>passPhrase</i> is used to decrypt it.</p>
<p>The socket's private key is set to the constructed key. The private key and the local <a href="qsslcertificate.html">certificate</a> are used by clients and servers that must prove their identity to SSL peers.</p>
<p>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.</p>
<p><b>See also </b><a href="qsslsocket.html#privateKey">privateKey</a>() and <a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a>().</p>
<!-- @@@setPrivateKey -->
<!-- $$$setProtocol[overload1]$$$setProtocolQSsl::SslProtocol -->
<h3 class="fn" id="setProtocol"><a name="setProtocol"></a><span class="type">void</span> QSslSocket::<span class="name">setProtocol</span>(<span class="type"><a href="qssl.html#SslProtocol-enum">QSsl::SslProtocol</a></span> <i>protocol</i>)</h3>
<p>Sets the socket's SSL protocol to <i>protocol</i>. This will affect the next initiated handshake; calling this function on an already-encrypted socket will not affect the socket's protocol.</p>
<p><b>See also </b><a href="qsslsocket.html#protocol">protocol</a>().</p>
<!-- @@@setProtocol -->
<!-- $$$setReadBufferSize[overload1]$$$setReadBufferSizeqint64 -->
<h3 class="fn" id="setReadBufferSize"><a name="setReadBufferSize"></a><code>[override virtual] </code><span class="type">void</span> QSslSocket::<span class="name">setReadBufferSize</span>(<span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> <i>size</i>)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#setReadBufferSize">QAbstractSocket::setReadBufferSize</a>().</p>
<p>Sets the size of <a href="qsslsocket.html">QSslSocket</a>'s internal read buffer to be <i>size</i> bytes.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@setReadBufferSize -->
<!-- $$$setSocketDescriptor[overload1]$$$setSocketDescriptorqintptrQAbstractSocket::SocketStateQIODevice::OpenMode -->
<h3 class="fn" id="setSocketDescriptor"><a name="setSocketDescriptor"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">setSocketDescriptor</span>(<span class="type"><a href="../qtcore/qtglobal.html#qintptr-typedef">qintptr</a></span> <i>socketDescriptor</i>, <span class="type"><a href="qabstractsocket.html#SocketState-enum">QAbstractSocket::SocketState</a></span> <i>state</i> = ConnectedState, <span class="type"><a href="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>openMode</i> = ReadWrite)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#setSocketDescriptor">QAbstractSocket::setSocketDescriptor</a>().</p>
<p>Initializes <a href="qsslsocket.html">QSslSocket</a> with the native socket descriptor <i>socketDescriptor</i>. Returns <code>true</code> if <i>socketDescriptor</i> is accepted as a valid socket descriptor; otherwise returns <code>false</code>. The socket is opened in the mode specified by <i>openMode</i>, and enters the socket state specified by <i>state</i>.</p>
<p><b>Note: </b>It is not possible to initialize two sockets with the same native socket descriptor.</p><p><b>See also </b><a href="qabstractsocket.html#socketDescriptor">socketDescriptor</a>().</p>
<!-- @@@setSocketDescriptor -->
<!-- $$$setSocketOption[overload1]$$$setSocketOptionQAbstractSocket::SocketOptionconstQVariant& -->
<h3 class="fn" id="setSocketOption"><a name="setSocketOption"></a><code>[override virtual] </code><span class="type">void</span> QSslSocket::<span class="name">setSocketOption</span>(<span class="type"><a href="qabstractsocket.html#SocketOption-enum">QAbstractSocket::SocketOption</a></span> <i>option</i>, const <span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> &amp;<i>value</i>)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#setSocketOption">QAbstractSocket::setSocketOption</a>().</p>
<p>Sets the given <i>option</i> to the value described by <i>value</i>.</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qsslsocket.html#socketOption">socketOption</a>().</p>
<!-- @@@setSocketOption -->
<!-- $$$setSslConfiguration[overload1]$$$setSslConfigurationconstQSslConfiguration& -->
<h3 class="fn" id="setSslConfiguration"><a name="setSslConfiguration"></a><span class="type">void</span> QSslSocket::<span class="name">setSslConfiguration</span>(const <span class="type"><a href="qsslconfiguration.html">QSslConfiguration</a></span> &amp;<i>configuration</i>)</h3>
<p>Sets the socket's SSL configuration to be the contents of <i>configuration</i>. This function sets the local certificate, the ciphers, the private key and the CA certificates to those stored in <i>configuration</i>.</p>
<p>It is not possible to set the SSL-state related fields.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#sslConfiguration">sslConfiguration</a>(), <a href="qsslsocket.html#setLocalCertificate">setLocalCertificate</a>(), <a href="qsslsocket.html#setPrivateKey">setPrivateKey</a>(), <a href="qsslsocket-obsolete.html#setCaCertificates">setCaCertificates</a>(), and <a href="qsslsocket-obsolete.html#setCiphers">setCiphers</a>().</p>
<!-- @@@setSslConfiguration -->
<!-- $$$socketOption[overload1]$$$socketOptionQAbstractSocket::SocketOption -->
<h3 class="fn" id="socketOption"><a name="socketOption"></a><code>[override virtual] </code><span class="type"><a href="../qtcore/qvariant.html">QVariant</a></span> QSslSocket::<span class="name">socketOption</span>(<span class="type"><a href="qabstractsocket.html#SocketOption-enum">QAbstractSocket::SocketOption</a></span> <i>option</i>)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#socketOption">QAbstractSocket::socketOption</a>().</p>
<p>Returns the value of the <i>option</i> option.</p>
<p>This function was introduced in  Qt 4.6.</p>
<p><b>See also </b><a href="qsslsocket.html#setSocketOption">setSocketOption</a>().</p>
<!-- @@@socketOption -->
<!-- $$$sslConfiguration[overload1]$$$sslConfiguration -->
<h3 class="fn" id="sslConfiguration"><a name="sslConfiguration"></a><span class="type"><a href="qsslconfiguration.html">QSslConfiguration</a></span> QSslSocket::<span class="name">sslConfiguration</span>() const</h3>
<p>Returns the socket's SSL configuration state. The default SSL configuration of a socket is to use the default ciphers, default CA certificates, no local private key or certificate.</p>
<p>The SSL configuration also contains fields that can change with time without notice.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qsslsocket.html#setSslConfiguration">setSslConfiguration</a>(), <a href="qsslsocket.html#localCertificate">localCertificate</a>(), <a href="qsslsocket.html#peerCertificate">peerCertificate</a>(), <a href="qsslsocket.html#peerCertificateChain">peerCertificateChain</a>(), <a href="qsslsocket.html#sessionCipher">sessionCipher</a>(), <a href="qsslsocket.html#privateKey">privateKey</a>(), <a href="qsslsocket-obsolete.html#ciphers">ciphers</a>(), and <a href="qsslsocket-obsolete.html#caCertificates">caCertificates</a>().</p>
<!-- @@@sslConfiguration -->
<!-- $$$sslErrors[overload1]$$$sslErrors -->
<h3 class="fn" id="sslErrors"><a name="sslErrors"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslerror.html">QSslError</a></span>&gt; QSslSocket::<span class="name">sslErrors</span>() const</h3>
<p>Returns a list of the last SSL errors that occurred. This is the same list as <a href="qsslsocket.html">QSslSocket</a> passes via the sslErrors() signal. If the connection has been encrypted with no errors, this function will return an empty list.</p>
<p><b>See also </b><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>().</p>
<!-- @@@sslErrors -->
<!-- $$$sslErrors$$$sslErrorsconstQList<QSslError>& -->
<h3 class="fn" id="sslErrors-1"><a name="sslErrors-1"></a><code>[signal] </code><span class="type">void</span> QSslSocket::<span class="name">sslErrors</span>(const <span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="qsslerror.html">QSslError</a></span>&gt; &amp;<i>errors</i>)</h3>
<p><a href="qsslsocket.html">QSslSocket</a> emits this signal after the SSL handshake to indicate that one or more errors have occurred while establishing the identity of the peer. The errors are usually an indication that <a href="qsslsocket.html">QSslSocket</a> is unable to securely identify the peer. Unless any action is taken, the connection will be dropped after this signal has been emitted.</p>
<p>If you want to continue connecting despite the errors that have occurred, you must call <a href="qsslsocket.html#ignoreSslErrors">QSslSocket::ignoreSslErrors</a>() from inside a slot connected to this signal. If you need to access the error list at a later point, you can call <a href="qsslsocket.html#sslErrors">sslErrors</a>() (without arguments).</p>
<p><i>errors</i> contains one or more errors that prevent <a href="qsslsocket.html">QSslSocket</a> from verifying the identity of the peer.</p>
<p><b>Note: </b>You cannot use <a href="../qtcore/qt.html#ConnectionType-enum">Qt::QueuedConnection</a> when connecting to this signal, or calling <a href="qsslsocket.html#ignoreSslErrors">QSslSocket::ignoreSslErrors</a>() will have no effect.</p><p><b>Note:</b> Signal <i>sslErrors</i> is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:<pre class="cpp">

  connect(sslSocket<span class="operator">,</span> <span class="type">QOverload</span><span class="operator">&lt;</span><span class="keyword">const</span> <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qsslerror.html">QSslError</a></span><span class="operator">&gt;</span> <span class="operator">&amp;</span><span class="operator">&gt;</span><span class="operator">::</span>of(<span class="operator">&amp;</span><span class="type"><a href="qsslsocket.html#QSslSocket">QSslSocket</a></span><span class="operator">::</span>sslErrors)<span class="operator">,</span>
      <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span>(<span class="keyword">const</span> <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qsslerror.html">QSslError</a></span><span class="operator">&gt;</span> <span class="operator">&amp;</span>errors){ <span class="comment">/* ... */</span> });

</pre>
<p><b>See also </b><a href="qsslsocket.html#peerVerifyError">peerVerifyError</a>().</p>
<!-- @@@sslErrors -->
<!-- $$$sslLibraryBuildVersionNumber[overload1]$$$sslLibraryBuildVersionNumber -->
<h3 class="fn" id="sslLibraryBuildVersionNumber"><a name="sslLibraryBuildVersionNumber"></a><code>[static] </code><span class="type">long</span> QSslSocket::<span class="name">sslLibraryBuildVersionNumber</span>()</h3>
<p>Returns the version number of the SSL library in use at compile time. If no SSL support is available then this will return an undefined value.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qsslsocket.html#sslLibraryVersionNumber">sslLibraryVersionNumber</a>().</p>
<!-- @@@sslLibraryBuildVersionNumber -->
<!-- $$$sslLibraryBuildVersionString[overload1]$$$sslLibraryBuildVersionString -->
<h3 class="fn" id="sslLibraryBuildVersionString"><a name="sslLibraryBuildVersionString"></a><code>[static] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSslSocket::<span class="name">sslLibraryBuildVersionString</span>()</h3>
<p>Returns the version string of the SSL library in use at compile time. If no SSL support is available then this will return an empty value.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qsslsocket.html#sslLibraryVersionString">sslLibraryVersionString</a>().</p>
<!-- @@@sslLibraryBuildVersionString -->
<!-- $$$sslLibraryVersionNumber[overload1]$$$sslLibraryVersionNumber -->
<h3 class="fn" id="sslLibraryVersionNumber"><a name="sslLibraryVersionNumber"></a><code>[static] </code><span class="type">long</span> QSslSocket::<span class="name">sslLibraryVersionNumber</span>()</h3>
<p>Returns the version number of the SSL library in use. Note that this is the version of the library in use at run-time not compile time. If no SSL support is available then this will return an undefined value.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@sslLibraryVersionNumber -->
<!-- $$$sslLibraryVersionString[overload1]$$$sslLibraryVersionString -->
<h3 class="fn" id="sslLibraryVersionString"><a name="sslLibraryVersionString"></a><code>[static] </code><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSslSocket::<span class="name">sslLibraryVersionString</span>()</h3>
<p>Returns the version string of the SSL library in use. Note that this is the version of the library in use at run-time not compile time. If no SSL support is available then this will return an empty value.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@sslLibraryVersionString -->
<!-- $$$startClientEncryption[overload1]$$$startClientEncryption -->
<h3 class="fn" id="startClientEncryption"><a name="startClientEncryption"></a><code>[slot] </code><span class="type">void</span> QSslSocket::<span class="name">startClientEncryption</span>()</h3>
<p>Starts a delayed SSL handshake for a client connection. This function can be called when the socket is in the <a href="qabstractsocket.html#SocketState-enum">ConnectedState</a> but still in the <a href="qsslsocket.html#SslMode-enum">UnencryptedMode</a>. If it is not yet connected, or if it is already encrypted, this function has no effect.</p>
<p>Clients that implement STARTTLS functionality often make use of delayed SSL handshakes. Most other clients can avoid calling this function directly by using <a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>() instead, which automatically performs the handshake.</p>
<p><b>See also </b><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>() and <a href="qsslsocket.html#startServerEncryption">startServerEncryption</a>().</p>
<!-- @@@startClientEncryption -->
<!-- $$$startServerEncryption[overload1]$$$startServerEncryption -->
<h3 class="fn" id="startServerEncryption"><a name="startServerEncryption"></a><code>[slot] </code><span class="type">void</span> QSslSocket::<span class="name">startServerEncryption</span>()</h3>
<p>Starts a delayed SSL handshake for a server connection. This function can be called when the socket is in the <a href="qabstractsocket.html#SocketState-enum">ConnectedState</a> but still in <a href="qsslsocket.html#SslMode-enum">UnencryptedMode</a>. If it is not connected or it is already encrypted, the function has no effect.</p>
<p>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 &quot;STARTTLS\r\n&quot; by calling this function).</p>
<p>The most common way to implement an SSL server is to create a subclass of <a href="qtcpserver.html">QTcpServer</a> and reimplement <a href="qtcpserver.html#incomingConnection">QTcpServer::incomingConnection</a>(). The returned socket descriptor is then passed to <a href="qsslsocket.html#setSocketDescriptor">QSslSocket::setSocketDescriptor</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>() and <a href="qsslsocket.html#startClientEncryption">startClientEncryption</a>().</p>
<!-- @@@startServerEncryption -->
<!-- $$$supportsSsl[overload1]$$$supportsSsl -->
<h3 class="fn" id="supportsSsl"><a name="supportsSsl"></a><code>[static] </code><span class="type">bool</span> QSslSocket::<span class="name">supportsSsl</span>()</h3>
<p>Returns <code>true</code> if this platform supports SSL; otherwise, returns false. If the platform doesn't support SSL, the socket will fail in the connection phase.</p>
<!-- @@@supportsSsl -->
<!-- $$$waitForBytesWritten[overload1]$$$waitForBytesWrittenint -->
<h3 class="fn" id="waitForBytesWritten"><a name="waitForBytesWritten"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">waitForBytesWritten</span>(<span class="type">int</span> <i>msecs</i> = 30000)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#waitForBytesWritten">QAbstractSocket::waitForBytesWritten</a>().</p>
<!-- @@@waitForBytesWritten -->
<!-- $$$waitForConnected[overload1]$$$waitForConnectedint -->
<h3 class="fn" id="waitForConnected"><a name="waitForConnected"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">waitForConnected</span>(<span class="type">int</span> <i>msecs</i> = 30000)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#waitForConnected">QAbstractSocket::waitForConnected</a>().</p>
<p>Waits until the socket is connected, or <i>msecs</i> milliseconds, whichever happens first. If the connection has been established, this function returns <code>true</code>; otherwise it returns <code>false</code>.</p>
<p><b>See also </b><a href="qabstractsocket.html#waitForConnected">QAbstractSocket::waitForConnected</a>().</p>
<!-- @@@waitForConnected -->
<!-- $$$waitForDisconnected[overload1]$$$waitForDisconnectedint -->
<h3 class="fn" id="waitForDisconnected"><a name="waitForDisconnected"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">waitForDisconnected</span>(<span class="type">int</span> <i>msecs</i> = 30000)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#waitForDisconnected">QAbstractSocket::waitForDisconnected</a>().</p>
<p>Waits until the socket has disconnected or <i>msecs</i> milliseconds, whichever comes first. If the connection has been disconnected, this function returns <code>true</code>; otherwise it returns <code>false</code>.</p>
<p><b>See also </b><a href="qabstractsocket.html#waitForDisconnected">QAbstractSocket::waitForDisconnected</a>().</p>
<!-- @@@waitForDisconnected -->
<!-- $$$waitForEncrypted[overload1]$$$waitForEncryptedint -->
<h3 class="fn" id="waitForEncrypted"><a name="waitForEncrypted"></a><span class="type">bool</span> QSslSocket::<span class="name">waitForEncrypted</span>(<span class="type">int</span> <i>msecs</i> = 30000)</h3>
<p>Waits until the socket has completed the SSL handshake and has emitted <a href="qsslsocket.html#encrypted">encrypted</a>(), or <i>msecs</i> milliseconds, whichever comes first. If <a href="qsslsocket.html#encrypted">encrypted</a>() has been emitted, this function returns true; otherwise (e.g&#x2e;, the socket is disconnected, or the SSL handshake fails), false is returned.</p>
<p>The following example waits up to one second for the socket to be encrypted:</p>
<pre class="cpp">

  socket<span class="operator">-</span><span class="operator">&gt;</span>connectToHostEncrypted(<span class="string">&quot;imap&quot;</span><span class="operator">,</span> <span class="number">993</span>);
  <span class="keyword">if</span> (socket<span class="operator">-</span><span class="operator">&gt;</span>waitForEncrypted(<span class="number">1000</span>))
      <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;Encrypted!&quot;</span>);

</pre>
<p>If msecs is -1, this function will not time out.</p>
<p><b>See also </b><a href="qsslsocket.html#startClientEncryption">startClientEncryption</a>(), <a href="qsslsocket.html#startServerEncryption">startServerEncryption</a>(), <a href="qsslsocket.html#encrypted">encrypted</a>(), and <a href="qsslsocket.html#isEncrypted">isEncrypted</a>().</p>
<!-- @@@waitForEncrypted -->
<!-- $$$waitForReadyRead[overload1]$$$waitForReadyReadint -->
<h3 class="fn" id="waitForReadyRead"><a name="waitForReadyRead"></a><code>[override virtual] </code><span class="type">bool</span> QSslSocket::<span class="name">waitForReadyRead</span>(<span class="type">int</span> <i>msecs</i> = 30000)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#waitForReadyRead">QAbstractSocket::waitForReadyRead</a>().</p>
<!-- @@@waitForReadyRead -->
<!-- $$$writeData[overload1]$$$writeDataconstchar*qint64 -->
<h3 class="fn" id="writeData"><a name="writeData"></a><code>[override virtual protected] </code><span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">writeData</span>(const <span class="type">char</span> *<i>data</i>, <span class="type"><a href="../qtcore/qtglobal.html#qint64-typedef">qint64</a></span> <i>len</i>)</h3>
<p>Reimplemented from <a href="qabstractsocket.html#writeData">QAbstractSocket::writeData</a>().</p>
<!-- @@@writeData -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>