summaryrefslogtreecommitdiff
path: root/ACE/protocols/ace/INet/SSL_CertificateCallback.h
blob: 328d8c4ef5f54ea77ea0d1f7565a97c454ad130f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// $Id$

/**
 * @file SSL_CertificateCallback.h
 *
 * @author Martin Corino <mcorino@remedy.nl>
 */

#ifndef ACE_SSL_CERTIFICATECALLBACK_H
#define ACE_SSL_CERTIFICATECALLBACK_H

#include /**/ "ace/pre.h"

#include "ace/SString.h"
#include "ace/SSL/SSL_Context.h"
#include "ace/INet/SSL_X509Cert.h"
#include "ace/INet/INet_SSL_Export.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE
  {
    namespace INet
      {
        /**
        * @class ACE_INet_SSL_CertificateCallbackArg
        *
        * @brief Encapsulates the arguments for an SSL certificate
        *   verification callback.
        *
        */
        class ACE_INET_SSL_Export SSL_CertificateCallbackArg
          {
            public:
              SSL_CertificateCallbackArg (const ACE_SSL_Context* ssl_ctx,
                                          ::X509_STORE_CTX* cert_ctx);
              ~SSL_CertificateCallbackArg ();

              const ACE_SSL_Context& context () const;

              SSL_X509Cert& certificate (void);

              int error_depth () const;

              int error_code () const;

              ACE_CString error_message () const;

              bool ignore_error () const;

              void ignore_error (bool f);

            private:
              const ACE_SSL_Context* ssl_ctx_;
              SSL_X509Cert ssl_cert_;
              int err_depth_;
              int err_code_;
              bool ignore_err_;
          };

        /**
        * @class ACE_INet_SSL_CertificateCallback
        *
        * @brief Abstract base class for SSL certificate
        *   verification callbacks.
        *
        */
        class ACE_INET_SSL_Export SSL_CertificateCallback
          {
            public:
              SSL_CertificateCallback ();
              virtual ~SSL_CertificateCallback ();

              virtual void handle_certificate_failure (SSL_CertificateCallbackArg& arg) = 0;
          };

        /**
        * @class ACE_INet_SSL_CertificateAcceptor
        *
        * @brief Implements an SSL certificate callback that accepts
        *   all peer certificates.
        *
        */
        class ACE_INET_SSL_Export SSL_CertificateAcceptor
          : public SSL_CertificateCallback
          {
            public:
              SSL_CertificateAcceptor ();
              virtual ~SSL_CertificateAcceptor ();

              virtual void handle_certificate_failure (SSL_CertificateCallbackArg& arg);
          };
      }
  }

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
#include "ace/INet/SSL_CertificateCallback.inl"
#endif

#include /**/ "ace/post.h"
#endif /* ACE_SSL_CERTIFICATECALLBACK_H */