Qpid Proton C++  0.14.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ssl.hpp
1 #ifndef PROTON_SSL_HPP
2 #define PROTON_SSL_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./internal/export.hpp"
26 #include "./internal/object.hpp"
27 
28 #include <proton/ssl.h>
29 
30 #include <string>
31 
32 namespace proton {
33 
34 class connection_options;
35 
37 class ssl {
39  ssl(pn_ssl_t* s) : object_(s) {}
41 
42  public:
44  ssl() : object_(0) {}
45 
47  enum verify_mode {
49  VERIFY_PEER = PN_SSL_VERIFY_PEER,
51  ANONYMOUS_PEER = PN_SSL_ANONYMOUS_PEER,
53  VERIFY_PEER_NAME = PN_SSL_VERIFY_PEER_NAME
54  };
55 
58  UNKNOWN = PN_SSL_RESUME_UNKNOWN,
59  NEW = PN_SSL_RESUME_NEW,
60  REUSED = PN_SSL_RESUME_REUSED
61  };
62 
64 
67  PN_CPP_EXTERN std::string cipher() const;
68 
71  PN_CPP_EXTERN std::string protocol() const;
72 
74  PN_CPP_EXTERN int ssf() const;
75 
77  PN_CPP_EXTERN std::string remote_subject() const;
78 
80  PN_CPP_EXTERN void resume_session_id(const std::string& session_id);
81 
82  PN_CPP_EXTERN enum resume_status resume_status() const;
83 
85 
86  private:
87  pn_ssl_t* object_;
88 
90  friend class internal::factory<ssl>;
92 };
93 
96  public:
98  PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main);
99 
100  // XXX Document the following constructors
101 
103  PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra);
104 
106  PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra, const std::string &passwd);
108 
109  private:
110  std::string certdb_main_;
111  std::string certdb_extra_;
112  std::string passwd_;
113  bool pw_set_;
114 
116  friend class ssl_client_options;
117  friend class ssl_server_options;
119 };
120 
121 class ssl_domain_impl;
122 
123 namespace internal {
124 
125 // Base class for SSL configuration
126 class ssl_domain {
127  public:
128  PN_CPP_EXTERN ssl_domain(const ssl_domain&);
129  PN_CPP_EXTERN ssl_domain& operator=(const ssl_domain&);
130  PN_CPP_EXTERN ~ssl_domain();
131 
132  protected:
133  ssl_domain(bool is_server);
134  pn_ssl_domain_t *pn_domain();
135 
136  private:
137  ssl_domain_impl *impl_;
138  bool server_type_;
139 };
140 
141 }
142 
144 class ssl_server_options : private internal::ssl_domain {
145  public:
148  PN_CPP_EXTERN ssl_server_options(ssl_certificate &cert);
149 
152  PN_CPP_EXTERN ssl_server_options(ssl_certificate &cert, const std::string &trust_db,
153  const std::string &advertise_db = std::string(),
154  enum ssl::verify_mode mode = ssl::VERIFY_PEER);
155 
158  PN_CPP_EXTERN ssl_server_options();
159 
160  private:
161  // Bring pn_domain into scope and allow connection_options to use
162  // it.
163  using internal::ssl_domain::pn_domain;
164 
166  friend class connection_options;
168 };
169 
171 class ssl_client_options : private internal::ssl_domain {
172  public:
174  PN_CPP_EXTERN ssl_client_options(const std::string &trust_db,
176 
178  PN_CPP_EXTERN ssl_client_options(ssl_certificate&, const std::string &trust_db,
180 
183  PN_CPP_EXTERN ssl_client_options();
184 
185  private:
186  // Bring pn_domain into scope and allow connection_options to use
187  // it.
188  using internal::ssl_domain::pn_domain;
189 
191  friend class connection_options;
193 };
194 
195 } // proton
196 
197 #endif // PROTON_SSL_HPP
ssl_server_options()
Server SSL options restricted to available anonymous cipher suites on the platform.
Experimental - SSL configuration for inbound connections.
Definition: ssl.hpp:144
ssl()
Create an empty ssl object.
Definition: ssl.hpp:44
SSL information.
Definition: ssl.hpp:37
Require valid certificate and matching name.
Definition: ssl.hpp:53
Session resume state unknown or not supported.
Definition: ssl.hpp:58
Options for creating a connection.
Definition: connection_options.hpp:67
Experimental - SSL configuration for outbound connections.
Definition: ssl.hpp:171
ssl_certificate(const std::string &certdb_main)
Create an SSL certificate.
resume_status
Outcome specifier for an attempted session resume.
Definition: ssl.hpp:57
ssl_client_options()
SSL connections restricted to available anonymous cipher suites on the platform.
verify_mode
Determines the level of peer validation.
Definition: ssl.hpp:47
Do not require a certificate or cipher authorization.
Definition: ssl.hpp:51
Require peer to provide a valid identifying certificate.
Definition: ssl.hpp:49
Session renegotiated, not resumed.
Definition: ssl.hpp:59
Experimental - An SSL certificate.
Definition: ssl.hpp:95
Session resumed from previous session.
Definition: ssl.hpp:60