Apache Mesos
utilities.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use this file except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License
12 
13 #ifndef __OPENSSL_UTIL_HPP__
14 #define __OPENSSL_UTIL_HPP__
15 
16 #ifdef USE_SSL_SOCKET
17 
18 #ifdef __WINDOWS__
19 // NOTE: This must be included before the OpenSSL headers as it includes
20 // `WinSock2.h` and `Windows.h` in the correct order.
21 #include <stout/windows.hpp>
22 #endif // __WINDOWS__
23 
24 #include <openssl/ssl.h>
25 #include <openssl/x509.h>
26 
27 #include <stout/ip.hpp>
28 #include <stout/nothing.hpp>
29 #include <stout/path.hpp>
30 #include <stout/try.hpp>
31 
32 namespace process {
33 namespace network {
34 namespace openssl {
35 
48 Try<EVP_PKEY*> generate_private_rsa_key(
49  int bits = 2048,
50  unsigned long exponent = RSA_F4);
51 
52 
86 Try<X509*> generate_x509(
87  EVP_PKEY* subject_key,
88  EVP_PKEY* sign_key,
89  const Option<X509*>& parent_certificate = None(),
90  int serial = 1,
91  int days = 365,
93  const Option<net::IP>& ip = None());
94 
95 
105 Try<Nothing> write_key_file(EVP_PKEY* private_key, const Path& path);
106 
107 
117 Try<Nothing> write_certificate_file(X509* x509, const Path& path);
118 
119 
129 Try<std::string> generate_hmac_sha256(
130  const std::string& message,
131  const std::string& key);
132 
133 } // namespace openssl {
134 } // namespace network {
135 } // namespace process {
136 
137 #endif // USE_SSL_SOCKET
138 
139 #endif // __OPENSSL_UTIL_HPP__
Definition: option.hpp:28
Definition: try.hpp:34
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:145
Try< std::string > hostname()
Definition: net.hpp:154
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
Definition: none.hpp:27