proton/ssl.hpp

Go to the documentation of this file.
00001 #ifndef PROTON_SSL_HPP
00002 #define PROTON_SSL_HPP
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "./internal/export.hpp"
00026 #include "./internal/config.hpp"
00027 
00028 #include <proton/ssl.h>
00029 
00030 #include <string>
00031 
00034 
00035 namespace proton {
00036 
00038 class ssl {
00040     ssl(pn_ssl_t* s) : object_(s) {}
00042 
00043 #if PN_CPP_HAS_DELETED_FUNCTIONS
00044     ssl() = delete;
00045 #else
00046     ssl();
00047 #endif
00048 
00049   public:
00051     enum verify_mode {
00053         VERIFY_PEER = PN_SSL_VERIFY_PEER,
00055         ANONYMOUS_PEER = PN_SSL_ANONYMOUS_PEER,
00057         VERIFY_PEER_NAME = PN_SSL_VERIFY_PEER_NAME
00058     };
00059 
00061     enum resume_status {
00062         UNKNOWN = PN_SSL_RESUME_UNKNOWN, 
00063         NEW = PN_SSL_RESUME_NEW,         
00064         REUSED = PN_SSL_RESUME_REUSED    
00065     };
00066 
00068 
00071     PN_CPP_EXTERN std::string cipher() const;
00072 
00075     PN_CPP_EXTERN std::string protocol() const;
00076 
00078     PN_CPP_EXTERN int ssf() const;
00079 
00081     PN_CPP_EXTERN std::string remote_subject() const;
00082 
00084     PN_CPP_EXTERN void resume_session_id(const std::string& session_id);
00085 
00086     PN_CPP_EXTERN enum resume_status resume_status() const;
00087 
00089 
00090   private:
00091     pn_ssl_t* const object_;
00092 
00094   friend class transport;
00096 };
00097 
00099 class ssl_certificate {
00100   public:
00102     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main);
00103 
00104     // XXX Document the following constructors
00105 
00107     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra);
00108 
00110     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra, const std::string &passwd);
00112 
00113   private:
00114     std::string certdb_main_;
00115     std::string certdb_extra_;
00116     std::string passwd_;
00117     bool pw_set_;
00118 
00120   friend class ssl_client_options;
00121   friend class ssl_server_options;
00123 };
00124 
00125 
00126 
00128 class ssl_server_options {
00129   public:
00132     PN_CPP_EXTERN ssl_server_options(const ssl_certificate &cert);
00133 
00136     PN_CPP_EXTERN ssl_server_options(const ssl_certificate &cert, const std::string &trust_db,
00137                                      const std::string &advertise_db = std::string(),
00138                                      enum ssl::verify_mode mode = ssl::VERIFY_PEER);
00139 
00142     PN_CPP_EXTERN ssl_server_options();
00143 
00144     PN_CPP_EXTERN ~ssl_server_options();
00145     PN_CPP_EXTERN ssl_server_options(const ssl_server_options&);
00146     PN_CPP_EXTERN ssl_server_options& operator=(const ssl_server_options&);
00147 
00148   private:
00149     class impl;
00150     impl* impl_;
00151 
00153   friend class connection_options;
00155 };
00156 
00158 class ssl_client_options {
00159   public:
00161     PN_CPP_EXTERN ssl_client_options();
00162 
00164     PN_CPP_EXTERN ssl_client_options(enum ssl::verify_mode);
00165 
00167     PN_CPP_EXTERN ssl_client_options(const std::string &trust_db,
00168                                      enum ssl::verify_mode = ssl::VERIFY_PEER_NAME);
00169 
00171     PN_CPP_EXTERN ssl_client_options(const ssl_certificate&, const std::string &trust_db,
00172                                      enum ssl::verify_mode = ssl::VERIFY_PEER_NAME);
00173 
00174     PN_CPP_EXTERN ~ssl_client_options();
00175     PN_CPP_EXTERN ssl_client_options(const ssl_client_options&);
00176     PN_CPP_EXTERN ssl_client_options& operator=(const ssl_client_options&);
00177 
00178   private:
00179     class impl;
00180     impl* impl_;
00181 
00183   friend class connection_options;
00185 };
00186 
00187 } // proton
00188 
00189 #endif // PROTON_SSL_HPP

Generated on 30 Jul 2020 for Qpid Proton C++ by  doxygen 1.6.1