diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2017-02-21 01:44:49 +0300 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2017-02-21 01:44:49 +0300 |
commit | 441063f8f8116a3524c63eb59fa98bcdd58d7e83 (patch) | |
tree | 685f13203030b1512f9fa70f64ecbf680805f422 /src/murmur/Server.h | |
parent | e75e737130da4246a6855a6eeb4172586b6e4245 (diff) |
Server, Cert: add Server::privateKeyFromPEM() method.
This adds a new method, Server::privateKeyFromPEM(), a helper
method for loading private keys.
In various places throughout the codebase, we use the same
sequence of operations for loading private keys from a PEM
bytestream.
This method moves that sequence to a single method, to avoid
the unnecessary duplication that is currently going on.
Diffstat (limited to 'src/murmur/Server.h')
-rw-r--r-- | src/murmur/Server.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/murmur/Server.h b/src/murmur/Server.h index b8cddf433..0d4d9ef73 100644 --- a/src/murmur/Server.h +++ b/src/murmur/Server.h @@ -169,6 +169,11 @@ class Server : public QThread { // Certificate stuff, implemented partially in Cert.cpp public: static bool isKeyForCert(const QSslKey &key, const QSslCertificate &cert); + /// Attempt to load a private key in PEM format from |buf|. + /// If |passphrase| is non-empty, it will be used for decrypting the private key in |buf|. + /// If a valid RSA, DSA or EC key is found, it is returned. + /// If no valid private key is found, a null QSslKey is returned. + static QSslKey privateKeyFromPEM(const QByteArray &buf, const QByteArray &pass = QByteArray()); void initializeCert(); const QString getDigest() const; |