join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
tlskey.hpp
Go to the documentation of this file.
1
25#ifndef __TLS_KEY_HPP__
26#define __TLS_KEY_HPP__
27
28// libjoin.
29#include <join/openssl.hpp>
30#include <join/base64.hpp>
31
32namespace join
33{
37 class TlsKey
38 {
39 public:
40 using Handle = EVP_PKEY*;
41
45 enum Type
46 {
49 };
50
54 TlsKey () = default;
55
61 TlsKey (const std::string& keyPath, Type keyType = Private);
62
67 TlsKey (const TlsKey& other) = delete;
68
74 TlsKey& operator= (const TlsKey& other) = delete;
75
80 TlsKey (TlsKey&& other);
81
87 TlsKey& operator= (TlsKey&& other);
88
92 ~TlsKey () = default;
93
99 explicit operator bool () const;
100
105 Handle handle () const;
106
111 int length ();
112
117 void swap (TlsKey& other);
118
123 Type type () const;
124
128 void clear ();
129
130 private:
137 static Handle readKey (const std::string& path, Type keyType = Private);
138
140 Type _type = Private;
141
143 EvpPkeyPtr _key;
144 };
145}
146
147#endif
manage private and public keys.
Definition tlskey.hpp:38
TlsKey()=default
default constructor.
TlsKey & operator=(const TlsKey &other)=delete
copy assignment operator.
~TlsKey()=default
destroy the signature stream buffer instance.
Handle handle() const
get a pointer to the native key handle.
Definition tlskey.cpp:84
Type
key type.
Definition tlskey.hpp:46
@ Private
Definition tlskey.hpp:48
@ Public
Definition tlskey.hpp:47
EVP_PKEY * Handle
Definition tlskey.hpp:40
int length()
return the length in bits of the key.
Definition tlskey.cpp:93
void clear()
clear the key.
Definition tlskey.cpp:122
Type type() const
return the key type.
Definition tlskey.cpp:113
void swap(TlsKey &other)
swap this key with other.
Definition tlskey.cpp:102
TlsKey(const TlsKey &other)=delete
copy constructor.
Definition acceptor.hpp:32
std::unique_ptr< EVP_PKEY, EvpPkeyDelete > EvpPkeyPtr
Definition openssl.hpp:88
std::string path
Definition unixstreamacceptor_test.cpp:34