Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
ssl_options.h
Go to the documentation of this file.
1 
8 /*******************************************************************************
9  * Copyright (c) 2016 Guilherme Ferreira <guilherme.maciel.ferreira@gmail.com>
10  *
11  * All rights reserved. This program and the accompanying materials
12  * are made available under the terms of the Eclipse Public License v1.0
13  * and Eclipse Distribution License v1.0 which accompany this distribution.
14  *
15  * The Eclipse Public License is available at
16  * http://www.eclipse.org/legal/epl-v10.html
17  * and the Eclipse Distribution License is available at
18  * http://www.eclipse.org/org/documents/edl-v10.php.
19  *
20  * Contributors:
21  * Guilherme Ferreira - initial implementation and documentation
22  * Frank Pagliughi - added copy & move operations
23  *******************************************************************************/
24 
25 #ifndef __mqtt_ssl_options_h
26 #define __mqtt_ssl_options_h
27 
28 #include "MQTTAsync.h"
29 #include "mqtt/message.h"
30 #include "mqtt/topic.h"
31 #include "mqtt/types.h"
32 #include <vector>
33 
34 namespace mqtt {
35 
37 
42 {
44  static const MQTTAsync_SSLOptions DFLT_C_STRUCT ;
45 
47  MQTTAsync_SSLOptions opts_;
48 
53  string trustStore_;
54 
56  string keyStore_;
57 
59  string privateKey_;
60 
62  string privateKeyPassword_;
63 
68  string enabledCipherSuites_;
69 
71  friend class connect_options;
72  friend class connect_options_test;
73  friend class ssl_options_test;
74 
85  const char* c_str(const string& str) {
86  return str.empty() ? nullptr : str.c_str();
87  }
91  void update_c_struct();
92 
93 public:
95  using ptr_t = std::shared_ptr<ssl_options>;
97  using const_ptr_t = std::shared_ptr<const ssl_options>;
98 
102  ssl_options();
117  ssl_options(const string& trustStore, const string& keyStore,
118  const string& privateKey, const string& privateKeyPassword,
119  const string& enabledCipherSuites, bool enableServerCertAuth);
124  ssl_options(const ssl_options& opt);
129  ssl_options(ssl_options&& opt);
135  ssl_options& operator=(const ssl_options& opt);
147  string get_trust_store() const { return trustStore_; }
152  string get_key_store() const { return keyStore_; }
157  string get_private_key() const { return privateKey_; }
162  string get_private_key_password() const { return privateKeyPassword_; }
168  string get_enabled_cipher_suites() const { return enabledCipherSuites_; }
174  return to_bool(opts_.enableServerCertAuth);
175  }
182  void set_trust_store(const string& trustStore);
189  void set_key_store(const string& keyStore);
196  void set_private_key(const string& privateKey);
202  void set_private_key_password(const string& privateKeyPassword);
220  void set_enabled_cipher_suites(const string& enabledCipherSuites);
226  void set_enable_server_cert_auth(bool enablServerCertAuth);
227 };
228 
232 using ssl_options_ptr = ssl_options::ptr_t;
233 
235 // end namespace mqtt
236 }
237 
238 #endif // __mqtt_ssl_options_h
239 
ssl_options()
Constructs a new MqttConnectOptions object using the default values.
string get_trust_store() const
Returns the file containing the public digital certificates trusted by the client.
Definition: ssl_options.h:147
Basic types and type conversions for the Paho MQTT C++ library.
Holds the set of SSL options for connection.
Definition: ssl_options.h:41
string get_private_key_password() const
Returns the password to load the client's privateKey if encrypted.
Definition: ssl_options.h:162
void set_enable_server_cert_auth(bool enablServerCertAuth)
Enables or disables verification of the server certificate.
Holds the set of options that control how the client connects to a server.
Definition: connect_options.h:46
Declaration of MQTT message class.
bool get_enable_server_cert_auth() const
Returns the true/false to enable verification of the server certificate .
Definition: ssl_options.h:173
void set_key_store(const string &keyStore)
Sets the file containing the public certificate chain of the client.
void set_private_key_password(const string &privateKeyPassword)
Sets the password to load the client's privateKey if encrypted.
void set_enabled_cipher_suites(const string &enabledCipherSuites)
Sets the list of cipher suites that the client will present to the server during the SSL handshake...
std::shared_ptr< const ssl_options > const_ptr_t
Smart/shared pointer to a const object of this class.
Definition: ssl_options.h:97
void set_trust_store(const string &trustStore)
Sets the file containing the public digital certificates trusted by the client.
string get_enabled_cipher_suites() const
Returns the list of cipher suites that the client will present to the server during the SSL handshake...
Definition: ssl_options.h:168
string get_private_key() const
Returns the file containing the client's private key.
Definition: ssl_options.h:157
string get_key_store() const
Returns the file containing the public certificate chain of the client.
Definition: ssl_options.h:152
ssl_options & operator=(const ssl_options &opt)
Copy assignment.
Declaration of MQTT topic class.
std::shared_ptr< ssl_options > ptr_t
Smart/shared pointer to an object of this class.
Definition: ssl_options.h:95
void set_private_key(const string &privateKey)
Sets the file containing the client's private key.