gloox  1.0.9
tlsgnutlsclient.h
1 /*
2  Copyright (c) 2007-2013 by Jakob Schroeter <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 #include <gcrypt.h>
27 
28 namespace gloox
29 {
30 
39  class GnuTLSClient : public GnuTLSBase
40  {
41  public:
47  GnuTLSClient( TLSHandler* th, const std::string& server );
48 
52  virtual ~GnuTLSClient();
53 
54  // reimplemented from TLSBase
55  virtual bool init( const std::string& clientKey = EmptyString,
56  const std::string& clientCerts = EmptyString,
57  const StringList& cacerts = StringList() );
58 
59  // reimplemented from TLSBase
60  virtual void setCACerts( const StringList& cacerts );
61 
62  // reimplemented from TLSBase
63  virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
64 
65  // reimplemented from TLSBase
66  virtual void cleanup();
67 
68  private:
69  virtual void getCertInfo();
70 
71  bool verifyAgainst( gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer );
72  bool verifyAgainstCAs( gnutls_x509_crt_t cert, gnutls_x509_crt_t *CAList, int CAListSize );
73 
74  gnutls_certificate_credentials m_credentials;
75 
76  };
77 
78 }
79 
80 #endif // HAVE_GNUTLS
81 
82 #endif // TLSGNUTLSCLIENT_H__