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 
00029 #include <proton/ssl.h>
00030 
00031 #include <string>
00032 
00035 
00036 namespace proton {
00037 
00039 class ssl {
00041     ssl(pn_ssl_t* s) : object_(s) {}
00043 
00044 #if PN_CPP_HAS_DELETED_FUNCTIONS
00045     ssl() = delete;
00046 #else
00047     ssl();
00048 #endif
00049 
00050   public:
00052     enum verify_mode {
00054         VERIFY_PEER = PN_SSL_VERIFY_PEER,
00056         ANONYMOUS_PEER = PN_SSL_ANONYMOUS_PEER,
00058         VERIFY_PEER_NAME = PN_SSL_VERIFY_PEER_NAME
00059     };
00060 
00062     enum resume_status {
00063         UNKNOWN = PN_SSL_RESUME_UNKNOWN, 
00064         NEW = PN_SSL_RESUME_NEW,         
00065         REUSED = PN_SSL_RESUME_REUSED    
00066     };
00067 
00069 
00072     PN_CPP_EXTERN std::string cipher() const;
00073 
00076     PN_CPP_EXTERN std::string protocol() const;
00077 
00079     PN_CPP_EXTERN int ssf() const;
00080 
00082     PN_CPP_EXTERN std::string remote_subject() const;
00083 
00085     PN_CPP_EXTERN void resume_session_id(const std::string& session_id);
00086 
00087     PN_CPP_EXTERN enum resume_status resume_status() const;
00088 
00090 
00091   private:
00092     pn_ssl_t* const object_;
00093 
00095   friend class transport;
00097 };
00098 
00100 class ssl_certificate {
00101   public:
00103     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main);
00104 
00105     // XXX Document the following constructors
00106 
00108     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra);
00109 
00111     PN_CPP_EXTERN ssl_certificate(const std::string &certdb_main, const std::string &certdb_extra, const std::string &passwd);
00113 
00114   private:
00115     std::string certdb_main_;
00116     std::string certdb_extra_;
00117     std::string passwd_;
00118     bool pw_set_;
00119 
00121   friend class ssl_client_options;
00122   friend class ssl_server_options;
00124 };
00125 
00126 class ssl_domain_impl;
00127 
00128 namespace internal {
00129 
00130 // Base class for SSL configuration
00131 class ssl_domain {
00132   public:
00133     PN_CPP_EXTERN ssl_domain(const ssl_domain&);
00134     PN_CPP_EXTERN ssl_domain& operator=(const ssl_domain&);
00135     PN_CPP_EXTERN ~ssl_domain();
00136 
00137   protected:
00138     ssl_domain(bool is_server);
00139     pn_ssl_domain_t *pn_domain();
00140 
00141   private:
00142     ssl_domain_impl *impl_;
00143     bool server_type_;
00144 };
00145 
00146 }
00147 
00149 class ssl_server_options : private internal::ssl_domain {
00150   public:
00153     PN_CPP_EXTERN ssl_server_options(ssl_certificate &cert);
00154 
00157     PN_CPP_EXTERN ssl_server_options(ssl_certificate &cert, const std::string &trust_db,
00158                                      const std::string &advertise_db = std::string(),
00159                                      enum ssl::verify_mode mode = ssl::VERIFY_PEER);
00160 
00163     PN_CPP_EXTERN ssl_server_options();
00164 
00165   private:
00166     // Bring pn_domain into scope and allow connection_options to use
00167     // it.
00168     using internal::ssl_domain::pn_domain;
00169 
00171   friend class connection_options;
00173 };
00174 
00176 class ssl_client_options : private internal::ssl_domain {
00177   public:
00179     PN_CPP_EXTERN ssl_client_options(const std::string &trust_db,
00180                                      enum ssl::verify_mode = ssl::VERIFY_PEER_NAME);
00181 
00183     PN_CPP_EXTERN ssl_client_options(ssl_certificate&, const std::string &trust_db,
00184                                      enum ssl::verify_mode = ssl::VERIFY_PEER_NAME);
00185 
00188     PN_CPP_EXTERN ssl_client_options();
00189 
00190   private:
00191     // Bring pn_domain into scope and allow connection_options to use
00192     // it.
00193     using internal::ssl_domain::pn_domain;
00194 
00196   friend class connection_options;
00198 };
00199 
00200 } // proton
00201 
00202 #endif // PROTON_SSL_HPP

Generated on 14 May 2019 for Qpid Proton C++ by  doxygen 1.6.1