summaryrefslogtreecommitdiffstats
path: root/src/network/ssl
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-19 03:23:19 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-19 03:23:19 (GMT)
commitdf6549d1b95af017305744af04a7bb3b10025660 (patch)
tree0919c82a21e0b0056f0eb180ce139c8ab99eb633 /src/network/ssl
parent84f984b24400aed7cc72fdf432a076f98bc142a2 (diff)
parent63d0b54df365380107cea7017c7893c7d04df13e (diff)
downloadQt-df6549d1b95af017305744af04a7bb3b10025660.zip
Qt-df6549d1b95af017305744af04a7bb3b10025660.tar.gz
Qt-df6549d1b95af017305744af04a7bb3b10025660.tar.bz2
Merge branch 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-master-from-4.7' of scm.dev.nokia.troll.no:qt/qt-integration: (351 commits) Fix compilation after merge fix for looping crash log on data abort Allow commenting of individual files in generated pkg files. Removed README.s60-mkspec. Fixed install docs for Qt for Symbian on Linux. Performance docs. Added symbian defs for e55781212532e2abcdd1cef8548b146fb14f0713 Check for binding having been deleted in more places Position GridView and ListView footer correctly when model cleared. Clean up particle motion documentation Finish QML for Qt Programmers section Distinguish Qt Quick, Qt Declarative and QML on the landing page Split responsibilities in QDeclarativeExpression more cleanly improvements to docs and examples Fix test for get() to check for undefined return values Enter key performs same action as Return key in QML demos. Revert "Making network reconnect happen after teardown." Revert "Adding some error checking for setdefaultif" Fixed a possible hanging bug in the Symbian networking. Fixed a network hanging bug on Symbian. ...
Diffstat (limited to 'src/network/ssl')
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp170
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h65
-rw-r--r--src/network/ssl/qsslsocket_p.h4
3 files changed, 229 insertions, 10 deletions
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 30428ff..1d794ae 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -68,6 +68,8 @@
PtrCertOpenSystemStoreW QSslSocketPrivate::ptrCertOpenSystemStoreW = 0;
PtrCertFindCertificateInStore QSslSocketPrivate::ptrCertFindCertificateInStore = 0;
PtrCertCloseStore QSslSocketPrivate::ptrCertCloseStore = 0;
+#elif defined(Q_OS_SYMBIAN)
+#include <QtCore/private/qcore_symbian_p.h>
#endif
QT_BEGIN_NAMESPACE
@@ -197,7 +199,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(SSL_CIPHER *ciph
ciph.d->protocol = QSsl::SslV2;
else if (protoString == QLatin1String("TLSv1"))
ciph.d->protocol = QSsl::TlsV1;
-
+
if (descriptionList.at(2).startsWith(QLatin1String("Kx=")))
ciph.d->keyExchangeMethod = descriptionList.at(2).mid(3);
if (descriptionList.at(3).startsWith(QLatin1String("Au=")))
@@ -365,7 +367,7 @@ init_context:
// Set verification depth.
if (configuration.peerVerifyDepth != 0)
q_SSL_CTX_set_verify_depth(ctx, configuration.peerVerifyDepth);
-
+
// Create and initialize SSL session
if (!(ssl = q_SSL_new(ctx))) {
// ### Bad error code
@@ -515,9 +517,15 @@ void QSslSocketPrivate::ensureInitialized()
#elif defined(Q_OS_WIN)
HINSTANCE hLib = LoadLibraryW(L"Crypt32");
if (hLib) {
+#if defined(Q_OS_WINCE)
+ ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, L"CertOpenStore");
+ ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, L"CertFindCertificateInStore");
+ ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, L"CertCloseStore");
+#else
ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
+#endif
if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
qWarning("could not resolve symbols in crypt32 library"); // should never happen
} else {
@@ -559,6 +567,124 @@ void QSslSocketPrivate::resetDefaultCiphers()
setDefaultCiphers(ciphers);
}
+#if defined(Q_OS_SYMBIAN)
+
+QCertificateRetriever::QCertificateRetriever(QCertificateConsumer* parent)
+ : CActive(EPriorityStandard)
+ , certStore(0)
+ , certFilter(0)
+ , consumer(parent)
+ , currentCertificateIndex(0)
+ , certDescriptor(0, 0)
+{
+ CActiveScheduler::Add(this);
+ QT_TRAP_THROWING(certStore = CUnifiedCertStore::NewL(qt_s60GetRFs(), EFalse));
+ QT_TRAP_THROWING(certFilter = CCertAttributeFilter::NewL());
+ certFilter->SetFormat(EX509Certificate);
+}
+
+QCertificateRetriever::~QCertificateRetriever()
+{
+ delete certFilter;
+ delete certStore;
+ Cancel();
+}
+
+void QCertificateRetriever::fetch()
+{
+ certStore->Initialize(iStatus);
+ state = Initializing;
+ SetActive();
+}
+
+void QCertificateRetriever::list()
+{
+ certStore->List(certs, *certFilter, iStatus);
+ state = Listing;
+ SetActive();
+}
+
+void QCertificateRetriever::retrieveNextCertificate()
+{
+ CCTCertInfo* cert = certs[currentCertificateIndex];
+ currentCertificate.resize(cert->Size());
+ certDescriptor.Set((TUint8*)currentCertificate.data(), 0, currentCertificate.size());
+ certStore->Retrieve(*cert, certDescriptor, iStatus);
+ state = RetrievingCertificates;
+ SetActive();
+}
+
+void QCertificateRetriever::RunL()
+{
+ QT_TRYCATCH_LEAVING(run());
+}
+
+void QCertificateRetriever::run()
+{
+ switch (state) {
+ case Initializing:
+ list();
+ break;
+ case Listing:
+ currentCertificateIndex = 0;
+ retrieveNextCertificate();
+ break;
+ case RetrievingCertificates:
+ consumer->addEncodedCertificate(currentCertificate);
+ currentCertificate = QByteArray();
+
+ currentCertificateIndex++;
+
+ if (currentCertificateIndex < certs.Count())
+ retrieveNextCertificate();
+ else
+ consumer->finish();
+ break;
+ }
+}
+
+void QCertificateRetriever::DoCancel()
+{
+ switch (state) {
+ case Initializing:
+ certStore->CancelInitialize();
+ break;
+ case Listing:
+ certStore->CancelList();
+ break;
+ case RetrievingCertificates:
+ certStore->CancelRetrieve();
+ break;
+ }
+}
+
+QCertificateConsumer::QCertificateConsumer(QObject* parent)
+ : QObject(parent)
+ , retriever(0)
+{
+}
+
+QCertificateConsumer::~QCertificateConsumer()
+{
+ delete retriever;
+}
+
+void QCertificateConsumer::finish()
+{
+ delete retriever;
+ retriever = 0;
+ emit finished();
+}
+
+void QCertificateConsumer::start()
+{
+ retriever = new QCertificateRetriever(this);
+ Q_CHECK_PTR(retriever);
+ retriever->fetch();
+}
+
+#endif // defined(Q_OS_SYMBIAN)
+
QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
{
ensureInitialized();
@@ -601,7 +727,15 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
#elif defined(Q_OS_WIN)
if (ptrCertOpenSystemStoreW && ptrCertFindCertificateInStore && ptrCertCloseStore) {
HCERTSTORE hSystemStore;
+#if defined(Q_OS_WINCE)
+ hSystemStore = ptrCertOpenSystemStoreW(CERT_STORE_PROV_SYSTEM_W,
+ 0,
+ 0,
+ CERT_STORE_NO_CRYPT_RELEASE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
+ L"ROOT");
+#else
hSystemStore = ptrCertOpenSystemStoreW(0, L"ROOT");
+#endif
if(hSystemStore) {
PCCERT_CONTEXT pc = NULL;
while(1) {
@@ -615,19 +749,35 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
ptrCertCloseStore(hSystemStore, 0);
}
}
-#elif defined(Q_OS_AIX)
- systemCerts.append(QSslCertificate::fromPath(QLatin1String("/var/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard));
-#elif defined(Q_OS_SOLARIS)
- systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard));
-#elif defined(Q_OS_HPUX)
- systemCerts.append(QSslCertificate::fromPath(QLatin1String("/opt/openssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard));
-#elif defined(Q_OS_LINUX)
+#elif defined(Q_OS_UNIX)
+ systemCerts.append(QSslCertificate::fromPath(QLatin1String("/var/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // AIX
+ systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Solaris
+ systemCerts.append(QSslCertificate::fromPath(QLatin1String("/opt/openssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // HP-UX
systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // (K)ubuntu, OpenSUSE, Mandriva, ...
systemCerts.append(QSslCertificate::fromPath(QLatin1String("/etc/pki/tls/certs/ca-bundle.crt"), QSsl::Pem)); // Fedora
systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/lib/ssl/certs/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Gentoo, Mandrake
systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/share/ssl/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Centos, Redhat, SuSE
systemCerts.append(QSslCertificate::fromPath(QLatin1String("/usr/local/ssl/*.pem"), QSsl::Pem, QRegExp::Wildcard)); // Normal OpenSSL Tarball
+#elif defined(Q_OS_SYMBIAN)
+ QThread* certThread = new QThread;
+
+ QCertificateConsumer *consumer = new QCertificateConsumer();
+ consumer->moveToThread(certThread);
+ QObject::connect(certThread, SIGNAL(started()), consumer, SLOT(start()));
+ QObject::connect(consumer, SIGNAL(finished()), certThread, SLOT(quit()), Qt::DirectConnection);
+
+ certThread->start();
+ certThread->wait();
+ foreach (const QByteArray &encodedCert, consumer->encodedCertificates()) {
+ QSslCertificate cert(encodedCert, QSsl::Der);
+ if (!cert.isNull())
+ systemCerts.append(cert);
+ }
+
+ delete consumer;
+ delete certThread;
#endif
+
return systemCerts;
}
@@ -673,7 +823,7 @@ void QSslSocketBackendPrivate::transmit()
bool transmitting;
do {
transmitting = false;
-
+
// If the connection is secure, we can transfer data from the write
// buffer (in plain text) to the write BIO through SSL_write.
if (connectionEncrypted && !writeBuffer.isEmpty()) {
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 3c08757..987dfae 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -118,6 +118,71 @@ public:
static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
};
+#if defined(Q_OS_SYMBIAN)
+#include <unifiedcertstore.h> // link against certstore.lib
+#include <ccertattributefilter.h> // link against ctframework.lib
+
+class QCertificateRetriever;
+
+class QCertificateConsumer : public QObject
+{
+ Q_OBJECT
+public:
+ QCertificateConsumer(QObject* parent = 0);
+ ~QCertificateConsumer();
+
+ void finish();
+
+ void addEncodedCertificate(const QByteArray& certificate)
+ { certificates.append(certificate); }
+ QList<QByteArray> encodedCertificates() const { return certificates; }
+
+public slots:
+ void start();
+
+signals:
+ void finished();
+
+private:
+ QList<QByteArray> certificates;
+ QCertificateRetriever *retriever;
+};
+
+
+class QCertificateRetriever : public CActive
+{
+public:
+ QCertificateRetriever(QCertificateConsumer* consumer);
+ ~QCertificateRetriever();
+
+ void fetch();
+
+private:
+ virtual void RunL();
+ virtual void DoCancel();
+
+ void run();
+ void list();
+ void retrieveNextCertificate();
+
+ enum {
+ Initializing,
+ Listing,
+ RetrievingCertificates
+ } state;
+
+ CUnifiedCertStore* certStore;
+ RMPointerArray<CCTCertInfo> certs;
+ CCertAttributeFilter* certFilter;
+ QCertificateConsumer* consumer;
+ int currentCertificateIndex;
+ QByteArray currentCertificate;
+ TPtr8 certDescriptor;
+};
+
+#endif
+
+
QT_END_NAMESPACE
#endif
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 09775bc..72b3ef7 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -77,7 +77,11 @@ QT_BEGIN_NAMESPACE
#ifndef HCRYPTPROV_LEGACY
#define HCRYPTPROV_LEGACY HCRYPTPROV
#endif
+#if defined(Q_OS_WINCE)
+ typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(LPCSTR, DWORD, HCRYPTPROV_LEGACY, DWORD, const void*);
+#else
typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(HCRYPTPROV_LEGACY, LPCWSTR);
+#endif
typedef PCCERT_CONTEXT (WINAPI *PtrCertFindCertificateInStore)(HCERTSTORE, DWORD, DWORD, DWORD, const void*, PCCERT_CONTEXT);
typedef BOOL (WINAPI *PtrCertCloseStore)(HCERTSTORE, DWORD);
#endif