diff options
author | Tobias Markmann <tm@ayena.de> | 2018-01-15 12:43:44 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2018-02-02 08:56:47 (GMT) |
commit | 9e2eee27d47ff1523677eb3881b4edcf66d7c0db (patch) | |
tree | c354e42f8b5314e1727da4aa8d9a248311e4242a /Swiften/TLS/PrivateKey.h | |
parent | 9eaa75b907a515a65ccb2002632fbf2f30c5aee8 (diff) | |
download | swift-9e2eee27d47ff1523677eb3881b4edcf66d7c0db.zip swift-9e2eee27d47ff1523677eb3881b4edcf66d7c0db.tar.bz2 |
Add support for extracting certificate chain from PEM string
Add PrivateKey class to simply encapsulate arbitrary private
key data and the corresponding password.
This enables easy unit testing by loading the certificate and
key from within a test case.
Test-Information:
Added unit tests for certificate and key generated by OpenSSL.
Tested on macOS 10.13.2 with OpenSSL.
Change-Id: I1c9ffc3c70f61af65c4f1c48670badaf74b672b7
Diffstat (limited to 'Swiften/TLS/PrivateKey.h')
-rw-r--r-- | Swiften/TLS/PrivateKey.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Swiften/TLS/PrivateKey.h b/Swiften/TLS/PrivateKey.h new file mode 100644 index 0000000..332fc48 --- /dev/null +++ b/Swiften/TLS/PrivateKey.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> + +#include <boost/optional.hpp> + +#include <Swiften/Base/SafeByteArray.h> +#include <Swiften/TLS/PrivateKey.h> + +namespace Swift { + +class PrivateKey { +public: + using ref = std::shared_ptr<PrivateKey>; + +public: + PrivateKey(const SafeByteArray& data, boost::optional<SafeByteArray> password = boost::optional<SafeByteArray>()); + + const SafeByteArray& getData() const; + const boost::optional<SafeByteArray>& getPassword() const; + +private: + SafeByteArray data_; + boost::optional<SafeByteArray> password_; +}; + +} |