gloox  1.0.20
tlsgnutlsclient.h
1 /*
2  Copyright (c) 2007-2017 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 
15 #ifndef TLSGNUTLSCLIENT_H__
16 #define TLSGNUTLSCLIENT_H__
17 
18 #include "tlsgnutlsbase.h"
19 
20 #include "config.h"
21 
22 #ifdef HAVE_GNUTLS
23 
24 #include <gnutls/gnutls.h>
25 #include <gnutls/x509.h>
26 
27 namespace gloox
28 {
29 
38  class GnuTLSClient : public GnuTLSBase
39  {
40  public:
46  GnuTLSClient( TLSHandler* th, const std::string& server );
47 
51  virtual ~GnuTLSClient();
52 
53  // reimplemented from TLSBase
54  virtual bool init( const std::string& clientKey = EmptyString,
55  const std::string& clientCerts = EmptyString,
56  const StringList& cacerts = StringList() );
57 
58  // reimplemented from TLSBase
59  virtual void setCACerts( const StringList& cacerts );
60 
61  // reimplemented from TLSBase
62  virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
63 
64  // reimplemented from TLSBase
65  virtual void cleanup();
66 
67  private:
68  virtual void getCertInfo();
69 
70  bool verifyAgainst( gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer );
71  bool verifyAgainstCAs( gnutls_x509_crt_t cert, gnutls_x509_crt_t *CAList, int CAListSize );
72 
73  gnutls_certificate_credentials_t m_credentials;
74 
75  };
76 
77 }
78 
79 #endif // HAVE_GNUTLS
80 
81 #endif // TLSGNUTLSCLIENT_H__
std::list< std::string > StringList
Definition: gloox.h:1251
virtual bool init(const std::string &clientKey=EmptyString, const std::string &clientCerts=EmptyString, const StringList &cacerts=StringList())
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class implements a TLS backend using GnuTLS.
This is the common base class for (stream) encryption using GnuTLS.
Definition: tlsgnutlsbase.h:38
GnuTLSClient(TLSHandler *th, const std::string &server)
virtual void setCACerts(const StringList &cacerts)
virtual void setClientCert(const std::string &clientKey, const std::string &clientCerts)
virtual void cleanup()
An interface that allows for interacting with TLS implementations derived from TLSBase.
Definition: tlshandler.h:34
const std::string EmptyString
Definition: gloox.cpp:124