gloox  0.9.9.12
tlsgnutlsclient.h
1 /*
2  Copyright (c) 2007-2008 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 #ifdef _WIN32
21 # include "../config.h.win"
22 #elif defined( _WIN32_WCE )
23 # include "../config.h.win"
24 #else
25 # include "config.h"
26 #endif
27 
28 #ifdef HAVE_GNUTLS
29 
30 #include <gnutls/gnutls.h>
31 #include <gnutls/x509.h>
32 
33 namespace gloox
34 {
35 
44  class GnuTLSClient : public GnuTLSBase
45  {
46  public:
52  GnuTLSClient( TLSHandler *th, const std::string& server );
53 
57  virtual ~GnuTLSClient();
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  // re-implemented from TLSBase
66  virtual void cleanup();
67 
68  private:
69  virtual void init();
70  virtual void getCertInfo();
71 
72  bool verifyAgainst( gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer );
73  bool verifyAgainstCAs( gnutls_x509_crt_t cert, gnutls_x509_crt_t *CAList, int CAListSize );
74 
75  gnutls_certificate_credentials m_credentials;
76 
77  };
78 
79 }
80 
81 #endif // HAVE_GNUTLS
82 
83 #endif // TLSGNUTLSCLIENT_H__