diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-08-01 18:50:51 +0400 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2007-08-01 18:50:51 +0400 |
commit | fc94f492e0af2eee58da874b4b438dd7a865c005 (patch) | |
tree | 1b77c050f2cafdd0e5f359ab6ea8f29ce3a65b79 /src/murmur/Cert.cpp | |
parent | d13bb4642bf1e4194c6397ec6e7bf11c51d5aa19 (diff) |
Multiserver support
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@667 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src/murmur/Cert.cpp')
-rw-r--r-- | src/murmur/Cert.cpp | 61 |
1 files changed, 10 insertions, 51 deletions
diff --git a/src/murmur/Cert.cpp b/src/murmur/Cert.cpp index c7d5855cf..c2083c7e6 100644 --- a/src/murmur/Cert.cpp +++ b/src/murmur/Cert.cpp @@ -28,8 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "Cert.h"
#include "Server.h"
+#include "Meta.h"
#include <openssl/pem.h>
#include <openssl/conf.h>
@@ -52,39 +52,12 @@ int add_ext(X509 * crt, int nid, char *value) { return 1;
}
-Cert cert;
-
-Cert::Cert() : QObject() {
-}
-
-void Cert::initialize() {
- QByteArray crt, key, store;
-
+void Server::initializeCert() {
+ QByteArray crt, key;
+ crt = getConf("certificate", QString()).toByteArray();
+ key = getConf("key", QString()).toByteArray();
- if (! g_sp.qsSSLCert.isEmpty()) {
- QFile pem(g_sp.qsSSLCert);
- if (pem.open(QIODevice::ReadOnly)) {
- crt = pem.readAll();
- pem.close();
- } else {
- qWarning("Failed to read %s", qPrintable(g_sp.qsSSLCert));
- }
- }
- if (! g_sp.qsSSLKey.isEmpty()) {
- QFile pem(g_sp.qsSSLKey);
- if (pem.open(QIODevice::ReadOnly)) {
- key = pem.readAll();
- pem.close();
- } else {
- qWarning("Failed to read %s", qPrintable(g_sp.qsSSLKey));
- }
- }
- QFile pem(g_sp.qsSSLStore);
- if (pem.open(QIODevice::ReadOnly)) {
- store = pem.readAll();
- pem.close();
- }
if (! crt.isEmpty()) {
qscCert = QSslCertificate(crt);
if (qscCert.isNull()) {
@@ -99,7 +72,6 @@ void Cert::initialize() { }
}
-
if (! qscCert.isNull()) {
QSsl::KeyAlgorithm alg = qscCert.publicKey().algorithm();
@@ -123,8 +95,8 @@ void Cert::initialize() { if (! key.isEmpty() || ! crt.isEmpty()) {
qFatal("Certificate specified, but failed to load.");
}
- qskKey = QSslKey(store, QSsl::Rsa);
- qscCert = QSslCertificate(store);
+ qskKey = Meta::mp.qskKey;
+ qscCert = Meta::mp.qscCert;
if (qscCert.isNull() || qskKey.isNull()) {
qWarning("Generating new server certificate.");
@@ -173,13 +145,8 @@ void Cert::initialize() { if (qskKey.isNull())
qFatal("Key generation failed");
- QFile pemout(g_sp.qsSSLStore);
- if (! pemout.open(QIODevice::WriteOnly)) {
- qFatal("Failed to open keystore %s for writing.", qPrintable(g_sp.qsSSLStore));
- }
- pemout.write(qscCert.toPem());
- pemout.write(qskKey.toPem());
- pemout.close();
+ setConf("certificate", qscCert.toPem());
+ setConf("key", qskKey.toPem());
}
}
@@ -194,14 +161,6 @@ void Cert::initialize() { QSslSocket::setDefaultCiphers(pref);
}
-const QSslCertificate &Cert::getCert() const {
- return qscCert;
-}
-
-const QSslKey &Cert::getKey() const {
- return qskKey;
-}
-
-const QString Cert::getDigest() const {
+const QString Server::getDigest() const {
return QString::fromLatin1(qscCert.digest().toHex());
}
|