root/tls/init.hh
| Revision 868b365c127bbf4f0b52f22da03e32a94a4f6653, 2.0 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 3 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | |
| 3 | Copyright © 2009 Antti-Juhani Kaijanaho |
| 4 | |
| 5 | Alue is free software: you can redistribute it and/or modify it |
| 6 | under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | Alue is distributed in the hope that it will be useful, but |
| 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with Alue. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #ifndef GUARD_TLS_INIT_HH |
| 21 | #define GUARD_TLS_INIT_HH |
| 22 | |
| 23 | #include <boost/noncopyable.hpp> |
| 24 | #include <boost/shared_ptr.hpp> |
| 25 | #include <gnutls/gnutls.h> |
| 26 | |
| 27 | namespace tls |
| 28 | { |
| 29 | class init |
| 30 | { |
| 31 | public: |
| 32 | enum file_format { pem, der }; |
| 33 | private: |
| 34 | class inner : public boost::noncopyable |
| 35 | { |
| 36 | gnutls_certificate_credentials_t cred; |
| 37 | gnutls_dh_params_t dhparms; |
| 38 | gnutls_priority_t priority_cache; |
| 39 | public: |
| 40 | inner(const char *cert, const char *key, |
| 41 | file_format ff); |
| 42 | ~inner(); |
| 43 | |
| 44 | void init_session(gnutls_session_t &gs, |
| 45 | gnutls_connection_end_t); |
| 46 | }; |
| 47 | boost::shared_ptr<inner> the_inner; |
| 48 | public: |
| 49 | init(const char *cert, const char *key, file_format ff) |
| 50 | : the_inner(new inner(cert, key, ff)) {} |
| 51 | void init_session(gnutls_session_t &gs, |
| 52 | gnutls_connection_end_t gce) |
| 53 | { the_inner->init_session(gs, gce); } |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | #endif /* GUARD_TLS_INIT_HH */ |
Note: See TracBrowser
for help on using the browser.
