1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsslsocket.cpp -->
<title>Qt 4.8: QSslSocket Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtnetwork.html">QtNetwork</a></li>
<li>QSslSocket</li>
</ul>
</div>
</div>
<div class="content mainContent">
<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="#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="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#symbian-platform-security-requirements">Symbian Platform Security Requirements</a></li>
</ul>
</div>
<h1 class="title">QSslSocket Class Reference</h1>
<!-- $$$QSslSocket-brief -->
<p>The QSslSocket class provides an SSL encrypted socket for both clients and servers. <a href="#details">More...</a></p>
<!-- @@@QSslSocket -->
<pre class="cpp"> <span class="preprocessor">#include <QSslSocket></span></pre><p><b>Inherits: </b><a href="qtcpsocket.html">QTcpSocket</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<p>This class was introduced in Qt 4.3.</p>
<ul>
<li><a href="qsslsocket-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<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>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<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> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </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 & <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 & <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-2">addCaCertificates</a></b> ( const QList<QSslCertificate> & <i>certificates</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCertificate> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#caCertificates">caCertificates</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCipher> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#ciphers">ciphers</a></b> () const</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 & <i>hostName</i>, quint16 <i>port</i>, OpenMode <i>mode</i> = ReadWrite )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#connectToHostEncrypted-2">connectToHostEncrypted</a></b> ( const QString & <i>hostName</i>, quint16 <i>port</i>, const QString & <i>sslPeerName</i>, OpenMode <i>mode</i> = ReadWrite )</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-2">ignoreSslErrors</a></b> ( const QList<QSslError> & <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"> 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<QSslCertificate> </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"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setCaCertificates">setCaCertificates</a></b> ( const QList<QSslCertificate> & <i>certificates</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setCiphers">setCiphers</a></b> ( const QList<QSslCipher> & <i>ciphers</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setCiphers-2">setCiphers</a></b> ( const QString & <i>ciphers</i> )</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 & <i>certificate</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setLocalCertificate-2">setLocalCertificate</a></b> ( const QString & <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#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 & <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 & <i>key</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setPrivateKey-2">setPrivateKey</a></b> ( const QString & <i>fileName</i>, QSsl::KeyAlgorithm <i>algorithm</i> = QSsl::Rsa, QSsl::EncodingFormat <i>format</i> = QSsl::Pem, const QByteArray & <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#setReadBufferSize">setReadBufferSize</a></b> ( qint64 <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setSocketDescriptor">setSocketDescriptor</a></b> ( int <i>socketDescriptor</i>, SocketState <i>state</i> = ConnectedState, OpenMode <i>openMode</i> = ReadWrite )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setSocketOption">setSocketOption</a></b> ( QAbstractSocket::SocketOption <i>option</i>, const QVariant & <i>value</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 & <i>configuration</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#socketOption">socketOption</a></b> ( QAbstractSocket::SocketOption <i>option</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<QSslError> </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#waitForConnected">waitForConnected</a></b> ( int <i>msecs</i> = 30000 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#waitForDisconnected">waitForDisconnected</a></b> ( int <i>msecs</i> = 30000 )</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>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<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</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</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</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</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#close">close</a></b> ()</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 )</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 )</td></tr>
</table>
<ul>
<li class="fn">32 public functions inherited from <a href="qabstractsocket.html#public-functions">QAbstractSocket</a></li>
<li class="fn">33 public functions inherited from <a href="qiodevice.html#public-functions">QIODevice</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<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>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<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 & <i>error</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#sslErrors-2">sslErrors</a></b> ( const QList<QSslError> & <i>errors</i> )</td></tr>
</table>
<ul>
<li class="fn">6 signals inherited from <a href="qabstractsocket.html#signals">QAbstractSocket</a></li>
<li class="fn">4 signals inherited from <a href="qiodevice.html#signals">QIODevice</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<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 & <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 & <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-2">addDefaultCaCertificates</a></b> ( const QList<QSslCertificate> & <i>certificates</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCertificate> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#defaultCaCertificates">defaultCaCertificates</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCipher> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#defaultCiphers">defaultCiphers</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a></b> ( const QList<QSslCertificate> & <i>certificates</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a></b> ( const QList<QSslCipher> & <i>ciphers</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCipher> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#supportedCiphers">supportedCiphers</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>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QSslCertificate> </td><td class="memItemRight bottomAlign"><b><a href="qsslsocket.html#systemCaCertificates">systemCaCertificates</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<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> )</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> )</td></tr>
</table>
<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="qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="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="qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
<li class="fn">2 protected slots inherited from <a href="qabstractsocket.html#protected-slots">QAbstractSocket</a></li>
</ul>
<a name="details"></a>
<!-- $$$QSslSocket-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QSslSocket class provides an SSL encrypted socket for both clients and servers.</p>
<p>QSslSocket 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 SSLv3 and TLSv1. By default, QSslSocket uses TLSv1, 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 QSslSocket: 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 QSslSocket 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">QSslSocket</span> <span class="operator">*</span>socket <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QSslSocket</span>(<span class="keyword">this</span>);
<a href="qobject.html#connect">connect</a>(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">></span><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>(<span class="string">"imap.example.com"</span><span class="operator">,</span> <span class="number">993</span>);</pre>
<p>As with a plain <a href="qtcpsocket.html">QTcpSocket</a>, QSslSocket 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., before the <a href="qsslsocket.html#encrypted">encrypted</a>() signal is emitted). The data is queued in QSslSocket 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 QSslSocket 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(<span class="type">int</span> socketDescriptor)
{
<span class="type">QSslSocket</span> <span class="operator">*</span>serverSocket <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QSslSocket</span>;
<span class="keyword">if</span> (serverSocket<span class="operator">-</span><span class="operator">></span>setSocketDescriptor(socketDescriptor)) {
connect(serverSocket<span class="operator">,</span> SIGNAL(encrypted())<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(ready()));
serverSocket<span class="operator">-</span><span class="operator">></span>startServerEncryption();
} <span class="keyword">else</span> {
<span class="keyword">delete</span> serverSocket;
}
}</pre>
<p>If an error occurs, QSslSocket 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 QSslSocket and before the connection is attempted. This will allow QSslSocket 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 QSslSocket as a regular <a href="qtcpsocket.html">QTcpSocket</a>. When <a href="qiodevice.html#readyRead">readyRead</a>() is emitted, you can call <a href="qiodevice.html#read">read</a>(), <a href="qsslsocket.html#canReadLine">canReadLine</a>() and <a href="qiodevice.html#readLine">readLine</a>(), or <a href="qiodevice.html#getChar">getChar</a>() to read decrypted data from QSslSocket's internal buffer, and you can call <a href="qiodevice.html#write">write</a>() or <a href="qiodevice.html#putChar">putChar</a>() to write data back to the peer. QSslSocket 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, QSslSocket 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">QSslSocket</span> socket;
socket<span class="operator">.</span><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>(<span class="string">"http.example.com"</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="qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> socket<span class="operator">.</span>errorString();
<span class="keyword">return</span> <span class="keyword">false</span>;
}
socket<span class="operator">.</span><a href="qiodevice.html#write">write</a>(<span class="string">"GET / HTTP/1.0\r\n\r\n"</span>);
<span class="keyword">while</span> (socket<span class="operator">.</span>waitForReadyRead())
<a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> socket<span class="operator">.</span><a href="qiodevice.html#readAll">readAll</a>()<span class="operator">.</span>data();</pre>
<p>QSslSocket 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 <a href="qsslsocket.html#setCiphers">setCiphers</a>() and <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>().</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#setCaCertificates">setCaCertificates</a>(), <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>(), <a href="qsslsocket.html#addDefaultCaCertificates">addDefaultCaCertificates</a>(), and <a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>().</li>
</ul>
<p><b>Note:</b> If available, root certificates on Unix (excluding Mac OS X) 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 the static function <a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>() before the first SSL handshake is made in your application, (e.g. via "QSslSocket::setDefaultCaCertificates(<a href="qsslsocket.html#systemCaCertificates">QSslSocket::systemCaCertificates</a>());"), or call <a href="qsslsocket.html#setCaCertificates">setCaCertificates</a>() on your QSslSocket 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="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="qiodevice.html#bytesWritten">bytesWritten</a>() will get emitted as soon as data has been written to the TCP socket. For a QSslSocket, <a href="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>
<a name="symbian-platform-security-requirements"></a>
<h3>Symbian Platform Security Requirements</h3>
<p>On Symbian, processes which use this class must have the <tt>NetworkServices</tt> platform security capability. If the client process lacks this capability, operations will fail.</p>
<p>Platform security capabilities are added via the <a href="qmake-variable-reference.html#target-capability">TARGET.CAPABILITY</a> qmake variable.</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"><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>
<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"><tt>QSslSocket::VerifyNone</tt></td><td class="topAlign"><tt>0</tt></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"><tt>QSslSocket::QueryPeer</tt></td><td class="topAlign"><tt>1</tt></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"><tt>QSslSocket::VerifyPeer</tt></td><td class="topAlign"><tt>2</tt></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"><tt>QSslSocket::AutoVerifyPeer</tt></td><td class="topAlign"><tt>3</tt></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>
<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"><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>
<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"><tt>QSslSocket::UnencryptedMode</tt></td><td class="topAlign"><tt>0</tt></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"><tt>QSslSocket::SslClientMode</tt></td><td class="topAlign"><tt>1</tt></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"><tt>QSslSocket::SslServerMode</tt></td><td class="topAlign"><tt>2</tt></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>
<!-- @@@SslMode -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QSslSocket[overload1]$$$QSslSocketQObject* -->
<h3 class="fn"><a name="QSslSocket"></a>QSslSocket::<span class="name">QSslSocket</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a <a href="qsslsocket.html">QSslSocket</a> object. <i>parent</i> is passed to <a href="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 <a href="qsslsocket.html#defaultCiphers">defaultCiphers</a>().</p>
<!-- @@@QSslSocket -->
<!-- $$$~QSslSocket[overload1]$$$~QSslSocket -->
<h3 class="fn"><a name="dtor.QSslSocket"></a>QSslSocket::<span class="name">~QSslSocket</span> ()</h3>
<p>Destroys the <a href="qsslsocket.html">QSslSocket</a>.</p>
<!-- @@@~QSslSocket -->
<!-- $$$abort[overload1]$$$abort -->
<h3 class="fn"><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"><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> & <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.html#caCertificates">caCertificates</a>() and <a href="qsslsocket.html#setCaCertificates">setCaCertificates</a>().</p>
<!-- @@@addCaCertificate -->
<!-- $$$addCaCertificates[overload1]$$$addCaCertificatesconstQString&QSsl::EncodingFormatQRegExp::PatternSyntax -->
<h3 class="fn"><a name="addCaCertificates"></a><span class="type">bool</span> QSslSocket::<span class="name">addCaCertificates</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <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="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> can be explicit, or it can contain wildcards in the format specified by <i>syntax</i>. Returns true if one or more certificates are added to the socket's CA certificate database; otherwise returns false.</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"><a name="addCaCertificates-2"></a><span class="type">void</span> QSslSocket::<span class="name">addCaCertificates</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> & <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.html#caCertificates">caCertificates</a>() and <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>().</p>
<!-- @@@addCaCertificates -->
<!-- $$$addDefaultCaCertificate[overload1]$$$addDefaultCaCertificateconstQSslCertificate& -->
<h3 class="fn"><a name="addDefaultCaCertificate"></a><span class="type">void</span> QSslSocket::<span class="name">addDefaultCaCertificate</span> ( const <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> & <i>certificate</i> )<tt> [static]</tt></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.html#defaultCaCertificates">defaultCaCertificates</a>() and <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>().</p>
<!-- @@@addDefaultCaCertificate -->
<!-- $$$addDefaultCaCertificates[overload1]$$$addDefaultCaCertificatesconstQString&QSsl::EncodingFormatQRegExp::PatternSyntax -->
<h3 class="fn"><a name="addDefaultCaCertificates"></a><span class="type">bool</span> QSslSocket::<span class="name">addDefaultCaCertificates</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <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="qregexp.html#PatternSyntax-enum">QRegExp::PatternSyntax</a></span> <i>syntax</i> = QRegExp::FixedString )<tt> [static]</tt></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 true 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.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"><a name="addDefaultCaCertificates-2"></a><span class="type">void</span> QSslSocket::<span class="name">addDefaultCaCertificates</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> & <i>certificates</i> )<tt> [static]</tt></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.html#defaultCaCertificates">defaultCaCertificates</a>() and <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>().</p>
<!-- @@@addDefaultCaCertificates -->
<!-- $$$atEnd[overload1]$$$atEnd -->
<h3 class="fn"><a name="atEnd"></a><span class="type">bool</span> QSslSocket::<span class="name">atEnd</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#atEnd">QIODevice::atEnd</a>().</p>
<!-- @@@atEnd -->
<!-- $$$bytesAvailable[overload1]$$$bytesAvailable -->
<h3 class="fn"><a name="bytesAvailable"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">bytesAvailable</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#bytesAvailable">QIODevice::bytesAvailable</a>().</p>
<p>Returns the number of decrypted bytes that are immediately available for reading.</p>
<!-- @@@bytesAvailable -->
<!-- $$$bytesToWrite[overload1]$$$bytesToWrite -->
<h3 class="fn"><a name="bytesToWrite"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QSslSocket::<span class="name">bytesToWrite</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#bytesToWrite">QIODevice::bytesToWrite</a>().</p>
<p>Returns the number of unencrypted bytes that are waiting to be encrypted and written to the network.</p>
<!-- @@@bytesToWrite -->
<!-- $$$caCertificates[overload1]$$$caCertificates -->
<h3 class="fn"><a name="caCertificates"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> QSslSocket::<span class="name">caCertificates</span> () const</h3>
<p>Returns this socket's CA certificate database. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate. It can be moodified prior to the handshake with <a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>(), <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>(), and <a href="qsslsocket.html#setCaCertificates">setCaCertificates</a>().</p>
<p><b>Note:</b> On Unix, this method may return an empty list if the root certificates are loaded on demand.</p>
<p><b>See also </b><a href="qsslsocket.html#addCaCertificate">addCaCertificate</a>(), <a href="qsslsocket.html#addCaCertificates">addCaCertificates</a>(), and <a href="qsslsocket.html#setCaCertificates">setCaCertificates</a>().</p>
<!-- @@@caCertificates -->
<!-- $$$canReadLine[overload1]$$$canReadLine -->
<h3 class="fn"><a name="canReadLine"></a><span class="type">bool</span> QSslSocket::<span class="name">canReadLine</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#canReadLine">QIODevice::canReadLine</a>().</p>
<p>Returns true if you can read one while line (terminated by a single ASCII '\n' character) of decrypted characters; otherwise, false is returned.</p>
<!-- @@@canReadLine -->
<!-- $$$ciphers[overload1]$$$ciphers -->
<h3 class="fn"><a name="ciphers"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcipher.html">QSslCipher</a></span>> QSslSocket::<span class="name">ciphers</span> () const</h3>
<p>Returns this socket's current cryptographic cipher suite. This list is used during the socket's handshake phase for choosing a session cipher. The returned list of ciphers is ordered by descending preference. (i.e., the first cipher in the list is the most preferred cipher). The session cipher will be the first one in the list that is also supported by the peer.</p>
<p>By default, the handshake phase can choose any of the ciphers supported by this system's SSL libraries, which may vary from system to system. The list of ciphers supported by this system's SSL libraries is returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>(). You can restrict the list of ciphers used for choosing the session cipher for this socket by calling <a href="qsslsocket.html#setCiphers">setCiphers</a>() with a subset of the supported ciphers. You can revert to using the entire set by calling <a href="qsslsocket.html#setCiphers">setCiphers</a>() with the list returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<p>You can restrict the list of ciphers used for choosing the session cipher for <i>all</i> sockets by calling <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>() with a subset of the supported ciphers. You can revert to using the entire set by calling <a href="qsslsocket.html#setCiphers">setCiphers</a>() with the list returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#setCiphers">setCiphers</a>(), <a href="qsslsocket.html#defaultCiphers">defaultCiphers</a>(), <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>(), and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@ciphers -->
<!-- $$$close[overload1]$$$close -->
<h3 class="fn"><a name="close"></a><span class="type">void</span> QSslSocket::<span class="name">close</span> ()<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#close">QIODevice::close</a>().</p>
<!-- @@@close -->
<!-- $$$connectToHostEncrypted[overload1]$$$connectToHostEncryptedconstQString&quint16OpenMode -->
<h3 class="fn"><a name="connectToHostEncrypted"></a><span class="type">void</span> QSslSocket::<span class="name">connectToHostEncrypted</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>hostName</i>, <span class="type"><a href="qtglobal.html#quint16-typedef">quint16</a></span> <i>port</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = ReadWrite )</h3>
<p>Starts an encrypted connection to the device <i>hostName</i> on <i>port</i>, using <i>mode</i> as the <a href="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>().</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</a></span> socket;
<a href="qobject.html#connect">connect</a>(<span class="operator">&</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">"imap"</span><span class="operator">,</span> <span class="number">993</span>);
socket<span class="operator">-</span><span class="operator">></span><a href="qiodevice.html#write">write</a>(<span class="string">"1 CAPABILITY\r\n"</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="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&OpenMode -->
<h3 class="fn"><a name="connectToHostEncrypted-2"></a><span class="type">void</span> QSslSocket::<span class="name">connectToHostEncrypted</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>hostName</i>, <span class="type"><a href="qtglobal.html#quint16-typedef">quint16</a></span> <i>port</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>sslPeerName</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = ReadWrite )</h3>
<p>This is an overloaded function.</p>
<p>In addition to the original behaviour of connectToHostEncrypted, 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 -->
<!-- $$$defaultCaCertificates[overload1]$$$defaultCaCertificates -->
<h3 class="fn"><a name="defaultCaCertificates"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> QSslSocket::<span class="name">defaultCaCertificates</span> ()<tt> [static]</tt></h3>
<p>Returns the current default CA certificate database. This database is originally set to your system's default CA certificate database. If no system default database is found, an empty database will be returned. You can override the default CA certificate database with your own CA certificate database using <a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>().</p>
<p>Each SSL socket's CA certificate database is initialized to the default CA certificate database.</p>
<p><b>Note:</b> On Unix, this method may return an empty list if the root certificates are loaded on demand.</p>
<p><b>See also </b><a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>() and <a href="qsslsocket.html#caCertificates">caCertificates</a>().</p>
<!-- @@@defaultCaCertificates -->
<!-- $$$defaultCiphers[overload1]$$$defaultCiphers -->
<h3 class="fn"><a name="defaultCiphers"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcipher.html">QSslCipher</a></span>> QSslSocket::<span class="name">defaultCiphers</span> ()<tt> [static]</tt></h3>
<p>Returns the default cryptographic cipher suite for all sockets in this application. This list is used during the socket's handshake phase when negotiating with the peer to choose a session cipher. The list is ordered by preference (i.e., the first cipher in the list is the most preferred cipher).</p>
<p>By default, the handshake phase can choose any of the ciphers supported by this system's SSL libraries, which may vary from system to system. The list of ciphers supported by this system's SSL libraries is returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>() and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@defaultCiphers -->
<!-- $$$encrypted[overload1]$$$encrypted -->
<h3 class="fn"><a name="encrypted"></a><span class="type">void</span> QSslSocket::<span class="name">encrypted</span> ()<tt> [signal]</tt></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"><a name="encryptedBytesAvailable"></a><span class="type"><a href="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"><a name="encryptedBytesToWrite"></a><span class="type"><a href="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"><a name="encryptedBytesWritten"></a><span class="type">void</span> QSslSocket::<span class="name">encryptedBytesWritten</span> ( <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>written</i> )<tt> [signal]</tt></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="qiodevice.html#bytesWritten">QIODevice::bytesWritten</a>().</p>
<!-- @@@encryptedBytesWritten -->
<!-- $$$flush[overload1]$$$flush -->
<h3 class="fn"><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 true; 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="qiodevice.html#write">write</a>() and <a href="qsslsocket.html#waitForBytesWritten">waitForBytesWritten</a>().</p>
<!-- @@@flush -->
<!-- $$$ignoreSslErrors[overload1]$$$ignoreSslErrors -->
<h3 class="fn"><a name="ignoreSslErrors"></a><span class="type">void</span> QSslSocket::<span class="name">ignoreSslErrors</span> ()<tt> [slot]</tt></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., 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>Ignoring errors that occur during an SSL handshake should be done with caution. A fundamental characteristic of secure connections is that they should be established with an error free handshake.</p>
<p><b>See also </b><a href="qsslsocket.html#sslErrors">sslErrors</a>().</p>
<!-- @@@ignoreSslErrors -->
<!-- $$$ignoreSslErrors$$$ignoreSslErrorsconstQList<QSslError>& -->
<h3 class="fn"><a name="ignoreSslErrors-2"></a><span class="type">void</span> QSslSocket::<span class="name">ignoreSslErrors</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslerror.html">QSslError</a></span>> & <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>Note that you can set the expected certificate in the SSL error: 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="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span><span class="operator">></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">"server-certificate.pem"</span>));
<span class="type"><a href="qsslerror.html">QSslError</a></span> <a href="qabstractsocket.html#error">error</a>(<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="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qsslerror.html">QSslError</a></span><span class="operator">></span> expectedSslErrors;
expectedSslErrors<span class="operator">.</span>append(error);
<span class="type"><a href="qsslsocket.html">QSslSocket</a></span> socket;
socket<span class="operator">.</span><a href="qsslsocket.html#ignoreSslErrors">ignoreSslErrors</a>(expectedSslErrors);
socket<span class="operator">.</span><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>(<span class="string">"server.tld"</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"><a name="isEncrypted"></a><span class="type">bool</span> QSslSocket::<span class="name">isEncrypted</span> () const</h3>
<p>Returns true if the socket is encrypted; otherwise, false is returned.</p>
<p>An encrypted socket encrypts all data that is written by calling <a href="qiodevice.html#write">write</a>() or <a href="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="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readLine">readLine</a>() or <a href="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"><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 -->
<!-- $$$mode[overload1]$$$mode -->
<h3 class="fn"><a name="mode"></a><span class="type"><a href="qsslsocket.html#SslMode-enum">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"><a name="modeChanged"></a><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> )<tt> [signal]</tt></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"><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., 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"><a name="peerCertificateChain"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> 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"><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"><a name="peerVerifyError"></a><span class="type">void</span> QSslSocket::<span class="name">peerVerifyError</span> ( const <span class="type"><a href="qsslerror.html">QSslError</a></span> & <i>error</i> )<tt> [signal]</tt></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"><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 mode decides whether <a href="qsslsocket.html">QSslSocket</a> should request a certificate from the peer (i.e., the client requests a certificate from the server, or a server requesting a certificate from the client), and whether it should require that this certificate is valid.</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"><a name="peerVerifyName"></a><span class="type"><a href="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 setPeerVerifyName or by connectToHostEncrypted.</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 -->
<!-- $$$privateKey[overload1]$$$privateKey -->
<h3 class="fn"><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"><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"><a name="readData"></a><span class="type"><a href="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="qtglobal.html#qint64-typedef">qint64</a></span> <i>maxlen</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#readData">QIODevice::readData</a>().</p>
<!-- @@@readData -->
<!-- $$$sessionCipher[overload1]$$$sessionCipher -->
<h3 class="fn"><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.html#ciphers">ciphers</a>(), <a href="qsslsocket.html#setCiphers">setCiphers</a>(), <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>(), <a href="qsslsocket.html#defaultCiphers">defaultCiphers</a>(), and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@sessionCipher -->
<!-- $$$setCaCertificates[overload1]$$$setCaCertificatesconstQList<QSslCertificate>& -->
<h3 class="fn"><a name="setCaCertificates"></a><span class="type">void</span> QSslSocket::<span class="name">setCaCertificates</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> & <i>certificates</i> )</h3>
<p>Sets this socket's CA certificate database to be <i>certificates</i>. The certificate database must be set prior to the SSL handshake. The CA certificate database is used by the socket during the handshake phase to validate the peer's certificate.</p>
<p>The CA certificate database can be reset to the current default CA certificate database by calling this function with the list of CA certificates returned by <a href="qsslsocket.html#defaultCaCertificates">defaultCaCertificates</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#caCertificates">caCertificates</a>() and <a href="qsslsocket.html#defaultCaCertificates">defaultCaCertificates</a>().</p>
<!-- @@@setCaCertificates -->
<!-- $$$setCiphers[overload1]$$$setCiphersconstQList<QSslCipher>& -->
<h3 class="fn"><a name="setCiphers"></a><span class="type">void</span> QSslSocket::<span class="name">setCiphers</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcipher.html">QSslCipher</a></span>> & <i>ciphers</i> )</h3>
<p>Sets the cryptographic cipher suite for this socket to <i>ciphers</i>, which must contain a subset of the ciphers in the list returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<p>Restricting the cipher suite must be done before the handshake phase, where the session cipher is chosen.</p>
<p><b>See also </b><a href="qsslsocket.html#ciphers">ciphers</a>(), <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>(), and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@setCiphers -->
<!-- $$$setCiphers$$$setCiphersconstQString& -->
<h3 class="fn"><a name="setCiphers-2"></a><span class="type">void</span> QSslSocket::<span class="name">setCiphers</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>ciphers</i> )</h3>
<p>Sets the cryptographic cipher suite for this socket to <i>ciphers</i>, which is a colon-separated list of cipher suite names. The ciphers are listed in order of preference, starting with the most preferred cipher. For example:</p>
<pre class="cpp"> <span class="type"><a href="qsslsocket.html">QSslSocket</a></span> socket;
socket<span class="operator">.</span><a href="qsslsocket.html#setCiphers">setCiphers</a>(<span class="string">"DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA"</span>);</pre>
<p>Each cipher name in <i>ciphers</i> must be the name of a cipher in the list returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>(). Restricting the cipher suite must be done before the handshake phase, where the session cipher is chosen.</p>
<p><b>See also </b><a href="qsslsocket.html#ciphers">ciphers</a>(), <a href="qsslsocket.html#setDefaultCiphers">setDefaultCiphers</a>(), and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@setCiphers -->
<!-- $$$setDefaultCaCertificates[overload1]$$$setDefaultCaCertificatesconstQList<QSslCertificate>& -->
<h3 class="fn"><a name="setDefaultCaCertificates"></a><span class="type">void</span> QSslSocket::<span class="name">setDefaultCaCertificates</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> & <i>certificates</i> )<tt> [static]</tt></h3>
<p>Sets the default CA certificate database to <i>certificates</i>. The default CA certificate database is originally set to your system's default CA certificate database. You can override the default CA certificate database with your own CA certificate database using this function.</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.html#defaultCaCertificates">defaultCaCertificates</a>() and <a href="qsslsocket.html#addDefaultCaCertificate">addDefaultCaCertificate</a>().</p>
<!-- @@@setDefaultCaCertificates -->
<!-- $$$setDefaultCiphers[overload1]$$$setDefaultCiphersconstQList<QSslCipher>& -->
<h3 class="fn"><a name="setDefaultCiphers"></a><span class="type">void</span> QSslSocket::<span class="name">setDefaultCiphers</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcipher.html">QSslCipher</a></span>> & <i>ciphers</i> )<tt> [static]</tt></h3>
<p>Sets the default cryptographic cipher suite for all sockets in this application to <i>ciphers</i>, which must contain a subset of the ciphers in the list returned by <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<p>Restricting the default cipher suite only affects SSL sockets that perform their handshake phase after the default cipher suite has been changed.</p>
<p><b>See also </b><a href="qsslsocket.html#setCiphers">setCiphers</a>(), <a href="qsslsocket.html#defaultCiphers">defaultCiphers</a>(), and <a href="qsslsocket.html#supportedCiphers">supportedCiphers</a>().</p>
<!-- @@@setDefaultCiphers -->
<!-- $$$setLocalCertificate[overload1]$$$setLocalCertificateconstQSslCertificate& -->
<h3 class="fn"><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> & <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>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"><a name="setLocalCertificate-2"></a><span class="type">void</span> QSslSocket::<span class="name">setLocalCertificate</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <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 -->
<!-- $$$setPeerVerifyDepth[overload1]$$$setPeerVerifyDepthint -->
<h3 class="fn"><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"><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., 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"><a name="setPeerVerifyName"></a><span class="type">void</span> QSslSocket::<span class="name">setPeerVerifyName</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <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"><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> & <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"><a name="setPrivateKey-2"></a><span class="type">void</span> QSslSocket::<span class="name">setPrivateKey</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <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="qbytearray.html">QByteArray</a></span> & <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"><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"><a name="setReadBufferSize"></a><span class="type">void</span> QSslSocket::<span class="name">setReadBufferSize</span> ( <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>size</i> )</h3>
<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]$$$setSocketDescriptorintSocketStateOpenMode -->
<h3 class="fn"><a name="setSocketDescriptor"></a><span class="type">bool</span> QSslSocket::<span class="name">setSocketDescriptor</span> ( <span class="type">int</span> <i>socketDescriptor</i>, <span class="type"><a href="qabstractsocket.html#SocketState-enum">SocketState</a></span> <i>state</i> = ConnectedState, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>openMode</i> = ReadWrite )</h3>
<p>Initializes <a href="qsslsocket.html">QSslSocket</a> with the native socket descriptor <i>socketDescriptor</i>. Returns true if <i>socketDescriptor</i> is accepted as a valid socket descriptor; otherwise returns false. 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"><a name="setSocketOption"></a><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="qvariant.html">QVariant</a></span> & <i>value</i> )</h3>
<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"><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> & <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.html#setCaCertificates">setCaCertificates</a>(), and <a href="qsslsocket.html#setCiphers">setCiphers</a>().</p>
<!-- @@@setSslConfiguration -->
<!-- $$$socketOption[overload1]$$$socketOptionQAbstractSocket::SocketOption -->
<h3 class="fn"><a name="socketOption"></a><span class="type"><a href="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>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"><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.html#ciphers">ciphers</a>(), and <a href="qsslsocket.html#caCertificates">caCertificates</a>().</p>
<!-- @@@sslConfiguration -->
<!-- $$$sslErrors[overload1]$$$sslErrors -->
<h3 class="fn"><a name="sslErrors"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslerror.html">QSslError</a></span>> 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"><a name="sslErrors-2"></a><span class="type">void</span> QSslSocket::<span class="name">sslErrors</span> ( const <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslerror.html">QSslError</a></span>> & <i>errors</i> )<tt> [signal]</tt></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>Note: You cannot use <a href="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>See also </b><a href="qsslsocket.html#peerVerifyError">peerVerifyError</a>().</p>
<!-- @@@sslErrors -->
<!-- $$$startClientEncryption[overload1]$$$startClientEncryption -->
<h3 class="fn"><a name="startClientEncryption"></a><span class="type">void</span> QSslSocket::<span class="name">startClientEncryption</span> ()<tt> [slot]</tt></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"><a name="startServerEncryption"></a><span class="type">void</span> QSslSocket::<span class="name">startServerEncryption</span> ()<tt> [slot]</tt></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 "STARTTLS\r\n" 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 -->
<!-- $$$supportedCiphers[overload1]$$$supportedCiphers -->
<h3 class="fn"><a name="supportedCiphers"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcipher.html">QSslCipher</a></span>> QSslSocket::<span class="name">supportedCiphers</span> ()<tt> [static]</tt></h3>
<p>Returns the list of cryptographic ciphers supported by this system. This list is set by the system's SSL libraries and may vary from system to system.</p>
<p><b>See also </b><a href="qsslsocket.html#defaultCiphers">defaultCiphers</a>(), <a href="qsslsocket.html#ciphers">ciphers</a>(), and <a href="qsslsocket.html#setCiphers">setCiphers</a>().</p>
<!-- @@@supportedCiphers -->
<!-- $$$supportsSsl[overload1]$$$supportsSsl -->
<h3 class="fn"><a name="supportsSsl"></a><span class="type">bool</span> QSslSocket::<span class="name">supportsSsl</span> ()<tt> [static]</tt></h3>
<p>Returns true if this platform supports SSL; otherwise, returns false. If the platform doesn't support SSL, the socket will fail in the connection phase.</p>
<!-- @@@supportsSsl -->
<!-- $$$systemCaCertificates[overload1]$$$systemCaCertificates -->
<h3 class="fn"><a name="systemCaCertificates"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span>> QSslSocket::<span class="name">systemCaCertificates</span> ()<tt> [static]</tt></h3>
<p>This function provides the CA certificate database provided by the operating system. The CA certificate database returned by this function is used to initialize the database returned by <a href="qsslsocket.html#defaultCaCertificates">defaultCaCertificates</a>(). You can replace that database with your own with <a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>().</p>
<p><b>See also </b><a href="qsslsocket.html#caCertificates">caCertificates</a>(), <a href="qsslsocket.html#defaultCaCertificates">defaultCaCertificates</a>(), and <a href="qsslsocket.html#setDefaultCaCertificates">setDefaultCaCertificates</a>().</p>
<!-- @@@systemCaCertificates -->
<!-- $$$waitForBytesWritten[overload1]$$$waitForBytesWrittenint -->
<h3 class="fn"><a name="waitForBytesWritten"></a><span class="type">bool</span> QSslSocket::<span class="name">waitForBytesWritten</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#waitForBytesWritten">QIODevice::waitForBytesWritten</a>().</p>
<!-- @@@waitForBytesWritten -->
<!-- $$$waitForConnected[overload1]$$$waitForConnectedint -->
<h3 class="fn"><a name="waitForConnected"></a><span class="type">bool</span> QSslSocket::<span class="name">waitForConnected</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )</h3>
<p>Waits until the socket is connected, or <i>msecs</i> milliseconds, whichever happens first. If the connection has been established, this function returns true; otherwise it returns false.</p>
<p><b>See also </b><a href="qabstractsocket.html#waitForConnected">QAbstractSocket::waitForConnected</a>().</p>
<!-- @@@waitForConnected -->
<!-- $$$waitForDisconnected[overload1]$$$waitForDisconnectedint -->
<h3 class="fn"><a name="waitForDisconnected"></a><span class="type">bool</span> QSslSocket::<span class="name">waitForDisconnected</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )</h3>
<p>Waits until the socket has disconnected or <i>msecs</i> milliseconds, whichever comes first. If the connection has been disconnected, this function returns true; otherwise it returns false.</p>
<p><b>See also </b><a href="qabstractsocket.html#waitForDisconnected">QAbstractSocket::waitForDisconnected</a>().</p>
<!-- @@@waitForDisconnected -->
<!-- $$$waitForEncrypted[overload1]$$$waitForEncryptedint -->
<h3 class="fn"><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., 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">></span><a href="qsslsocket.html#connectToHostEncrypted">connectToHostEncrypted</a>(<span class="string">"imap"</span><span class="operator">,</span> <span class="number">993</span>);
<span class="keyword">if</span> (socket<span class="operator">-</span><span class="operator">></span>waitForEncrypted(<span class="number">1000</span>))
<a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">"Encrypted!"</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"><a name="waitForReadyRead"></a><span class="type">bool</span> QSslSocket::<span class="name">waitForReadyRead</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#waitForReadyRead">QIODevice::waitForReadyRead</a>().</p>
<!-- @@@waitForReadyRead -->
<!-- $$$writeData[overload1]$$$writeDataconstchar*qint64 -->
<h3 class="fn"><a name="writeData"></a><span class="type"><a href="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="qtglobal.html#qint64-typedef">qint64</a></span> <i>len</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice::writeData</a>().</p>
<!-- @@@writeData -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
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.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|