64 |
64 |
65 #include <private/qringbuffer_p.h> |
65 #include <private/qringbuffer_p.h> |
66 |
66 |
67 QT_BEGIN_NAMESPACE |
67 QT_BEGIN_NAMESPACE |
68 |
68 |
|
69 #if defined(Q_OS_MAC) |
|
70 #include <Security/SecCertificate.h> |
|
71 #include <CoreFoundation/CFArray.h> |
|
72 typedef OSStatus (*PtrSecCertificateGetData)(SecCertificateRef, CSSM_DATA_PTR); |
|
73 typedef OSStatus (*PtrSecTrustSettingsCopyCertificates)(int, CFArrayRef*); |
|
74 typedef OSStatus (*PtrSecTrustCopyAnchorCertificates)(CFArrayRef*); |
|
75 #elif defined(Q_OS_WIN) |
|
76 #include <wincrypt.h> |
|
77 #ifndef HCRYPTPROV_LEGACY |
|
78 #define HCRYPTPROV_LEGACY HCRYPTPROV |
|
79 #endif |
|
80 #if defined(Q_OS_WINCE) |
|
81 typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(LPCSTR, DWORD, HCRYPTPROV_LEGACY, DWORD, const void*); |
|
82 #else |
|
83 typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(HCRYPTPROV_LEGACY, LPCWSTR); |
|
84 #endif |
|
85 typedef PCCERT_CONTEXT (WINAPI *PtrCertFindCertificateInStore)(HCERTSTORE, DWORD, DWORD, DWORD, const void*, PCCERT_CONTEXT); |
|
86 typedef BOOL (WINAPI *PtrCertCloseStore)(HCERTSTORE, DWORD); |
|
87 #endif |
|
88 |
|
89 |
|
90 |
69 class QSslSocketPrivate : public QTcpSocketPrivate |
91 class QSslSocketPrivate : public QTcpSocketPrivate |
70 { |
92 { |
71 Q_DECLARE_PUBLIC(QSslSocket) |
93 Q_DECLARE_PUBLIC(QSslSocket) |
72 public: |
94 public: |
73 QSslSocketPrivate(); |
95 QSslSocketPrivate(); |
88 |
110 |
89 // if set, this hostname is used for certificate validation instead of the hostname |
111 // if set, this hostname is used for certificate validation instead of the hostname |
90 // that was used for connecting to. |
112 // that was used for connecting to. |
91 QString verificationPeerName; |
113 QString verificationPeerName; |
92 |
114 |
93 static bool ensureInitialized(); |
115 static bool supportsSsl(); |
|
116 static void ensureInitialized(); |
94 static void deinitialize(); |
117 static void deinitialize(); |
95 static QList<QSslCipher> defaultCiphers(); |
118 static QList<QSslCipher> defaultCiphers(); |
96 static QList<QSslCipher> supportedCiphers(); |
119 static QList<QSslCipher> supportedCiphers(); |
97 static void setDefaultCiphers(const QList<QSslCipher> &ciphers); |
120 static void setDefaultCiphers(const QList<QSslCipher> &ciphers); |
98 static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers); |
121 static void setDefaultSupportedCiphers(const QList<QSslCipher> &ciphers); |
103 static void setDefaultCaCertificates(const QList<QSslCertificate> &certs); |
126 static void setDefaultCaCertificates(const QList<QSslCertificate> &certs); |
104 static bool addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format, |
127 static bool addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format, |
105 QRegExp::PatternSyntax syntax); |
128 QRegExp::PatternSyntax syntax); |
106 static void addDefaultCaCertificate(const QSslCertificate &cert); |
129 static void addDefaultCaCertificate(const QSslCertificate &cert); |
107 static void addDefaultCaCertificates(const QList<QSslCertificate> &certs); |
130 static void addDefaultCaCertificates(const QList<QSslCertificate> &certs); |
|
131 |
|
132 #if defined(Q_OS_MAC) |
|
133 static PtrSecCertificateGetData ptrSecCertificateGetData; |
|
134 static PtrSecTrustSettingsCopyCertificates ptrSecTrustSettingsCopyCertificates; |
|
135 static PtrSecTrustCopyAnchorCertificates ptrSecTrustCopyAnchorCertificates; |
|
136 #elif defined(Q_OS_WIN) |
|
137 static PtrCertOpenSystemStoreW ptrCertOpenSystemStoreW; |
|
138 static PtrCertFindCertificateInStore ptrCertFindCertificateInStore; |
|
139 static PtrCertCloseStore ptrCertCloseStore; |
|
140 #endif |
108 |
141 |
109 // The socket itself, including private slots. |
142 // The socket itself, including private slots. |
110 QTcpSocket *plainSocket; |
143 QTcpSocket *plainSocket; |
111 void createPlainSocket(QIODevice::OpenMode openMode); |
144 void createPlainSocket(QIODevice::OpenMode openMode); |
112 void _q_connectedSlot(); |
145 void _q_connectedSlot(); |
124 virtual void startServerEncryption() = 0; |
157 virtual void startServerEncryption() = 0; |
125 virtual void transmit() = 0; |
158 virtual void transmit() = 0; |
126 virtual void disconnectFromHost() = 0; |
159 virtual void disconnectFromHost() = 0; |
127 virtual void disconnected() = 0; |
160 virtual void disconnected() = 0; |
128 virtual QSslCipher sessionCipher() const = 0; |
161 virtual QSslCipher sessionCipher() const = 0; |
|
162 |
|
163 private: |
|
164 static bool ensureLibraryLoaded(); |
|
165 static void ensureCiphersAndCertsLoaded(); |
|
166 |
|
167 static bool s_libraryLoaded; |
|
168 static bool s_loadedCiphersAndCerts; |
129 }; |
169 }; |
130 |
170 |
131 QT_END_NAMESPACE |
171 QT_END_NAMESPACE |
132 |
172 |
133 #endif |
173 #endif |