gloox  1.1-svn
tlsgnutlsclient.h
1 /*
2  Copyright (c) 2007-2009 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 cleanup();
61 
62  private:
63  virtual void setCACerts( const StringList& cacerts );
64  virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
65 
66  virtual void getCertInfo();
67 
68  bool verifyAgainst( gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer );
69  bool verifyAgainstCAs( gnutls_x509_crt_t cert, gnutls_x509_crt_t *CAList, int CAListSize );
70 
71  gnutls_certificate_credentials m_credentials;
72 
73  };
74 
75 }
76 
77 #endif // HAVE_GNUTLS
78 
79 #endif // TLSGNUTLSCLIENT_H__