qsslsocket.sip 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. // qsslsocket.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtNetwork Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. %If (PyQt_SSL)
  22. class QSslSocket : public QTcpSocket
  23. {
  24. %TypeHeaderCode
  25. #include <qsslsocket.h>
  26. %End
  27. public:
  28. enum SslMode
  29. {
  30. UnencryptedMode,
  31. SslClientMode,
  32. SslServerMode,
  33. };
  34. explicit QSslSocket(QObject *parent /TransferThis/ = 0);
  35. virtual ~QSslSocket();
  36. void connectToHostEncrypted(const QString &hostName, quint16 port, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol) /ReleaseGIL/;
  37. void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol) /ReleaseGIL/;
  38. virtual bool setSocketDescriptor(qintptr socketDescriptor, QAbstractSocket::SocketState state = QAbstractSocket::ConnectedState, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite);
  39. QSslSocket::SslMode mode() const;
  40. bool isEncrypted() const;
  41. QSsl::SslProtocol protocol() const;
  42. void setProtocol(QSsl::SslProtocol protocol);
  43. virtual qint64 bytesAvailable() const;
  44. virtual qint64 bytesToWrite() const;
  45. virtual bool canReadLine() const;
  46. virtual void close();
  47. virtual bool atEnd() const;
  48. void setLocalCertificate(const QSslCertificate &certificate);
  49. void setLocalCertificate(const QString &path, QSsl::EncodingFormat format = QSsl::Pem);
  50. QSslCertificate localCertificate() const;
  51. QSslCertificate peerCertificate() const;
  52. QList<QSslCertificate> peerCertificateChain() const;
  53. QSslCipher sessionCipher() const;
  54. void setPrivateKey(const QSslKey &key);
  55. void setPrivateKey(const QString &fileName, QSsl::KeyAlgorithm algorithm = QSsl::Rsa, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray &passPhrase = QByteArray());
  56. QSslKey privateKey() const;
  57. virtual bool waitForConnected(int msecs = 30000) /ReleaseGIL/;
  58. bool waitForEncrypted(int msecs = 30000) /ReleaseGIL/;
  59. virtual bool waitForReadyRead(int msecs = 30000) /ReleaseGIL/;
  60. virtual bool waitForBytesWritten(int msecs = 30000) /ReleaseGIL/;
  61. virtual bool waitForDisconnected(int msecs = 30000) /ReleaseGIL/;
  62. static bool supportsSsl();
  63. public slots:
  64. void startClientEncryption();
  65. void startServerEncryption();
  66. void ignoreSslErrors();
  67. signals:
  68. void encrypted();
  69. void sslErrors(const QList<QSslError> &errors);
  70. void modeChanged(QSslSocket::SslMode newMode);
  71. void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
  72. protected:
  73. virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="bytes",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)];
  74. %MethodCode
  75. // Return the data read or None if there was an error.
  76. if (a0 < 0)
  77. {
  78. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  79. sipIsErr = 1;
  80. }
  81. else
  82. {
  83. char *s = new char[a0];
  84. qint64 len;
  85. Py_BEGIN_ALLOW_THREADS
  86. #if defined(SIP_PROTECTED_IS_PUBLIC)
  87. len = sipSelfWasArg ? sipCpp->QSslSocket::readData(s, a0) : sipCpp->readData(s, a0);
  88. #else
  89. len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0);
  90. #endif
  91. Py_END_ALLOW_THREADS
  92. if (len < 0)
  93. {
  94. Py_INCREF(Py_None);
  95. sipRes = Py_None;
  96. }
  97. else
  98. {
  99. sipRes = PyBytes_FromStringAndSize(s, len);
  100. if (!sipRes)
  101. sipIsErr = 1;
  102. }
  103. delete[] s;
  104. }
  105. %End
  106. virtual qint64 writeData(SIP_PYBUFFER) /ReleaseGIL/ [qint64 (const char *data, qint64 len)];
  107. %MethodCode
  108. sipBufferInfoDef bi;
  109. if (sipGetBufferInfo(a0, &bi) > 0)
  110. {
  111. Py_BEGIN_ALLOW_THREADS
  112. #if defined(SIP_PROTECTED_IS_PUBLIC)
  113. sipRes = sipSelfWasArg ?
  114. sipCpp->QSslSocket::writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len) :
  115. sipCpp->writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
  116. #else
  117. sipRes = sipCpp->sipProtectVirt_writeData(sipSelfWasArg, reinterpret_cast<char *>(bi.bi_buf),
  118. bi.bi_len);
  119. #endif
  120. Py_END_ALLOW_THREADS
  121. sipReleaseBufferInfo(&bi);
  122. }
  123. else
  124. {
  125. sipIsErr = 1;
  126. }
  127. %End
  128. virtual qint64 skipData(qint64 maxSize) /ReleaseGIL/;
  129. public:
  130. enum PeerVerifyMode
  131. {
  132. VerifyNone,
  133. QueryPeer,
  134. VerifyPeer,
  135. AutoVerifyPeer,
  136. };
  137. QSslSocket::PeerVerifyMode peerVerifyMode() const;
  138. void setPeerVerifyMode(QSslSocket::PeerVerifyMode mode);
  139. int peerVerifyDepth() const;
  140. void setPeerVerifyDepth(int depth);
  141. virtual void setReadBufferSize(qint64 size);
  142. qint64 encryptedBytesAvailable() const;
  143. qint64 encryptedBytesToWrite() const;
  144. QSslConfiguration sslConfiguration() const;
  145. void setSslConfiguration(const QSslConfiguration &config);
  146. signals:
  147. void peerVerifyError(const QSslError &error);
  148. void encryptedBytesWritten(qint64 totalBytes);
  149. void newSessionTicketReceived();
  150. public:
  151. virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value);
  152. virtual QVariant socketOption(QAbstractSocket::SocketOption option);
  153. void ignoreSslErrors(const QList<QSslError> &errors);
  154. QString peerVerifyName() const;
  155. void setPeerVerifyName(const QString &hostName);
  156. virtual void resume() /ReleaseGIL/;
  157. virtual void connectToHost(const QString &hostName, quint16 port, QIODeviceBase::OpenMode mode = QIODeviceBase::ReadWrite, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol) /ReleaseGIL/;
  158. virtual void disconnectFromHost() /ReleaseGIL/;
  159. static long sslLibraryVersionNumber();
  160. static QString sslLibraryVersionString();
  161. void setLocalCertificateChain(const QList<QSslCertificate> &localChain);
  162. QList<QSslCertificate> localCertificateChain() const;
  163. QSsl::SslProtocol sessionProtocol() const;
  164. static long sslLibraryBuildVersionNumber();
  165. static QString sslLibraryBuildVersionString();
  166. QList<QOcspResponse> ocspResponses() const;
  167. QList<QSslError> sslHandshakeErrors() const;
  168. void continueInterruptedHandshake();
  169. signals:
  170. void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
  171. void alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
  172. void handshakeInterruptedOnError(const QSslError &error);
  173. public:
  174. %If (Qt_6_1_0 -)
  175. static QList<QString> availableBackends();
  176. %End
  177. %If (Qt_6_1_0 -)
  178. static QString activeBackend();
  179. %End
  180. %If (Qt_6_1_0 -)
  181. static bool setActiveBackend(const QString &backendName);
  182. %End
  183. %If (Qt_6_1_0 -)
  184. static QList<QSsl::SslProtocol> supportedProtocols(const QString &backendName = {});
  185. %End
  186. %If (Qt_6_1_0 -)
  187. static bool isProtocolSupported(QSsl::SslProtocol protocol, const QString &backendName = {});
  188. %End
  189. %If (Qt_6_1_0 -)
  190. static QList<QSsl::ImplementedClass> implementedClasses(const QString &backendName = {});
  191. %End
  192. %If (Qt_6_1_0 -)
  193. static bool isClassImplemented(QSsl::ImplementedClass cl, const QString &backendName = {});
  194. %End
  195. %If (Qt_6_1_0 -)
  196. static QList<QSsl::SupportedFeature> supportedFeatures(const QString &backendName = {});
  197. %End
  198. %If (Qt_6_1_0 -)
  199. static bool isFeatureSupported(QSsl::SupportedFeature feat, const QString &backendName = {});
  200. %End
  201. };
  202. %End