summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2012-02-03 17:34:55 +0100
committerMichael Neves2012-02-03 17:34:55 +0100
commit62c43631739066b9295e0c42ad6a7e5a2b6fb9ff (patch)
tree631a9a9349cad351173898cf3ba45779e823bc37
parentUser Private Key, Certificate und Server Certificate gesetzt (diff)
downloadfbgui-62c43631739066b9295e0c42ad6a7e5a2b6fb9ff.tar.gz
fbgui-62c43631739066b9295e0c42ad6a7e5a2b6fb9ff.tar.xz
fbgui-62c43631739066b9295e0c42ad6a7e5a2b6fb9ff.zip
mutual auth test
-rw-r--r--src/fbgui/fbgui.cpp33
-rw-r--r--src/fbgui/fbgui.h2
2 files changed, 28 insertions, 7 deletions
diff --git a/src/fbgui/fbgui.cpp b/src/fbgui/fbgui.cpp
index 2adcca3..b83d3bc 100644
--- a/src/fbgui/fbgui.cpp
+++ b/src/fbgui/fbgui.cpp
@@ -248,6 +248,7 @@ void fbgui::loadURL() {
//Add OpenSLX Certificate to SSLConfiguration
QList<QSslCertificate> certList = QSslCertificate::fromPath(QLatin1String("/usr/lib/ssl/openslx/CA/certs/openslx-cert.pem"));
+ certList.append(QSslCertificate::fromPath(QLatin1String("/usr/lib/ssl/openslx/CA/certs/pbsfr-cert.pem")));
setCACertificates(certList);
//Ignore the SelfSignedCertificateInChain-error for the OpenSLX-Certificate
@@ -262,7 +263,7 @@ void fbgui::loadURL() {
QFile keyFile("/usr/lib/ssl/openslx/CA/private/guest.pem");
Q_ASSERT(keyFile.open(QIODevice::ReadOnly));
QByteArray keyContent = keyFile.readAll();
- setPrivateKey(QSslKey(keyContent, QSsl::Rsa));
+ setPrivateKey(QSslKey(keyContent, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray("guest")));
@@ -283,6 +284,18 @@ void fbgui::loadURL() {
_qnr->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QObject::connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadURLDone(bool)));
_webView->load(*_qnr, QNetworkAccessManager::PostOperation, postData);
+
+// ////////////////////TEST///////////////////////
+// QSslSocket qssReg = new QSslSocket(this);
+// qssReg.setSslConfiguration(_qnr->sslConfiguration());
+//
+// QHttp http = new QHttp(QLatin1String("pbs2.mp.openslx.org"), QHttp::ConnectionModeHttps, 443, this);
+// http.setSocket(&qssReg);
+//
+// //QObject::connect(http, SIGNAL(done(bool)), this, SLOT(done(bool)));
+// QObject::connect(&http, SIGNAL(sslErrors(const QList<QSslError> &)), this,
+// SLOT(sslErrorHandler(const QList<QSslError> & )));
+
}
// TODO: error page if no host.
}
@@ -319,13 +332,21 @@ void fbgui::httpErrorHandler(QNetworkReply* reply) {
}
//Dump all Certificates in SSLConfiguration
-void fbgui::dumpCACertificates(){
+void fbgui::dumpSSLConfiguration(){
QSslConfiguration sslConfig = _qnr->sslConfiguration();
- QList<QSslCertificate> caCerts = sslConfig.caCertificates();
- foreach (QSslCertificate cert, caCerts){
- LOG4CXX_DEBUG(coreLogger,"Cert info: \n" << cert.toPem());
+ LOG4CXX_DEBUG(coreLogger,"****************SSLConfiguration************************** \n");
+ LOG4CXX_DEBUG(coreLogger,"CACertificates: \n");
+ foreach (QSslCertificate cert, sslConfig.caCertificates()){
+ LOG4CXX_DEBUG(coreLogger,cert.toPem() << "\n");
}
+ LOG4CXX_DEBUG(coreLogger,"----------------------------------------------------- \n");
+ LOG4CXX_DEBUG(coreLogger,"LocalCertificate: \n");
+ LOG4CXX_DEBUG(coreLogger,sslConfig.localCertificate().toPem() << "\n");
+ LOG4CXX_DEBUG(coreLogger,"----------------------------------------------------- \n");
+ LOG4CXX_DEBUG(coreLogger,"Private Key: \n");
+ LOG4CXX_DEBUG(coreLogger,sslConfig.privateKey().toPem() << "\n");
+ LOG4CXX_DEBUG(coreLogger,"********************************************************** \n");
}
//Saves CACertificates to SslConfiguration
@@ -359,7 +380,7 @@ void fbgui::setLocalCertificate(const QSslCertificate& cert){
//Saves PrivateKey to SslConfiguration
void fbgui::setPrivateKey(const QSslKey & key){
- LOG4CXX_DEBUG(coreLogger,"Is key valid: " << key.isNull());
+ LOG4CXX_DEBUG(coreLogger,"Key length: " << key.length());
QSslConfiguration sslConfig = _qnr->sslConfiguration();
sslConfig.setPrivateKey(key);
_qnr->setSslConfiguration(sslConfig);
diff --git a/src/fbgui/fbgui.h b/src/fbgui/fbgui.h
index 0c8d7d6..9247525 100644
--- a/src/fbgui/fbgui.h
+++ b/src/fbgui/fbgui.h
@@ -83,7 +83,7 @@ private:
void loadURL();
//Dump all Certificates in SSLConfiguration
- void dumpCACertificates();
+ void dumpSSLConfiguration();
QByteArray generatePOSTData();