~yadi/squid/http-context

« back to all changes in this revision

Viewing changes to src/ssl/PeerConnector.h

  • Committer: Amos Jeffries
  • Date: 2016-01-27 16:56:38 UTC
  • Revision ID: squid3@treenet.co.nz-20160127165638-oh33tsq2tkwb6bb4
SourceLayout: shuffle PeerConnector classes to separate units

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Please see the COPYING and CONTRIBUTORS files for details.
7
7
 */
8
8
 
9
 
#ifndef SQUID_SSL_PEER_CONNECTOR_H
10
 
#define SQUID_SSL_PEER_CONNECTOR_H
 
9
#ifndef SQUID_SRC_SSL_PEERCONNECTOR_H
 
10
#define SQUID_SRC_SSL_PEERCONNECTOR_H
11
11
 
12
12
#include "acl/Acl.h"
13
13
#include "base/AsyncCbdataCalls.h"
15
15
#include "CommCalls.h"
16
16
#include "security/EncryptorAnswer.h"
17
17
#include "ssl/support.h"
 
18
 
18
19
#include <iosfwd>
19
20
 
 
21
#if USE_OPENSSL
 
22
 
20
23
class HttpRequest;
21
24
class ErrorState;
22
25
 
23
26
namespace Ssl
24
27
{
25
28
 
26
 
class ErrorDetail;
27
 
class CertValidationResponse;
28
 
typedef RefCount<CertValidationResponse> CertValidationResponsePointer;
29
 
 
30
29
/**
31
30
 \par
32
31
 * Connects Squid to SSL/TLS-capable peers or services.
176
175
    bool useCertValidator_; ///< whether the certificate validator should bypassed
177
176
};
178
177
 
179
 
/// A simple PeerConnector for SSL/TLS cache_peers. No SslBump capabilities.
180
 
class BlindPeerConnector: public PeerConnector {
181
 
    CBDATA_CLASS(BlindPeerConnector);
182
 
public:
183
 
    BlindPeerConnector(HttpRequestPointer &aRequest,
184
 
                       const Comm::ConnectionPointer &aServerConn,
185
 
                       AsyncCall::Pointer &aCallback, const time_t timeout = 0) :
186
 
        AsyncJob("Ssl::BlindPeerConnector"),
187
 
        PeerConnector(aServerConn, aCallback, timeout)
188
 
    {
189
 
        request = aRequest;
190
 
    }
191
 
 
192
 
    /* PeerConnector API */
193
 
 
194
 
    /// Calls parent initializeSSL, configure the created SSL object to try reuse SSL session
195
 
    /// and sets the hostname to use for certificates validation
196
 
    virtual Security::SessionPtr initializeSsl();
197
 
 
198
 
    /// Return the configured Security::ContextPtr object
199
 
    virtual Security::ContextPtr getSslContext();
200
 
 
201
 
    /// On error calls peerConnectFailed function, on success store the used SSL session
202
 
    /// for later use
203
 
    virtual void noteNegotiationDone(ErrorState *error);
204
 
};
205
 
 
206
 
/// A PeerConnector for HTTP origin servers. Capable of SslBumping.
207
 
class PeekingPeerConnector: public PeerConnector {
208
 
    CBDATA_CLASS(PeekingPeerConnector);
209
 
public:
210
 
    PeekingPeerConnector(HttpRequestPointer &aRequest,
211
 
                         const Comm::ConnectionPointer &aServerConn,
212
 
                         const Comm::ConnectionPointer &aClientConn,
213
 
                         AsyncCall::Pointer &aCallback, const time_t timeout = 0) :
214
 
        AsyncJob("Ssl::PeekingPeerConnector"),
215
 
        PeerConnector(aServerConn, aCallback, timeout),
216
 
        clientConn(aClientConn),
217
 
        splice(false),
218
 
        resumingSession(false),
219
 
        serverCertificateHandled(false)
220
 
    {
221
 
        request = aRequest;
222
 
    }
223
 
 
224
 
    /* PeerConnector API */
225
 
    virtual Security::SessionPtr initializeSsl();
226
 
    virtual Security::ContextPtr getSslContext();
227
 
    virtual void noteWantWrite();
228
 
    virtual void noteSslNegotiationError(const int result, const int ssl_error, const int ssl_lib_error);
229
 
    virtual void noteNegotiationDone(ErrorState *error);
230
 
 
231
 
    /// Updates associated client connection manager members
232
 
    /// if the server certificate was received from the server.
233
 
    void handleServerCertificate();
234
 
 
235
 
    /// Initiates the ssl_bump acl check in step3 SSL bump step to decide
236
 
    /// about bumping, splicing or terminating the connection.
237
 
    void checkForPeekAndSplice();
238
 
 
239
 
    /// Callback function for ssl_bump acl check in step3  SSL bump step.
240
 
    void checkForPeekAndSpliceDone(allow_t answer);
241
 
 
242
 
    /// Handles the final bumping decision.
243
 
    void checkForPeekAndSpliceMatched(const Ssl::BumpMode finalMode);
244
 
 
245
 
    /// Guesses the final bumping decision when no ssl_bump rules match.
246
 
    Ssl::BumpMode checkForPeekAndSpliceGuess() const;
247
 
 
248
 
    /// Runs after the server certificate verified to update client
249
 
    /// connection manager members
250
 
    void serverCertificateVerified();
251
 
 
252
 
    /// A wrapper function for checkForPeekAndSpliceDone for use with acl
253
 
    static void cbCheckForPeekAndSpliceDone(allow_t answer, void *data);
254
 
 
255
 
private:
256
 
    Comm::ConnectionPointer clientConn; ///< TCP connection to the client
257
 
    AsyncCall::Pointer callback; ///< we call this with the results
258
 
    AsyncCall::Pointer closeHandler; ///< we call this when the connection closed
259
 
    bool splice; ///< whether we are going to splice or not
260
 
    bool resumingSession; ///< whether it is an SSL resuming session connection
261
 
    bool serverCertificateHandled; ///< whether handleServerCertificate() succeeded
262
 
};
263
 
 
264
178
} // namespace Ssl
265
179
 
266
 
#endif /* SQUID_PEER_CONNECTOR_H */
 
180
#endif /* USE_OPENSSL */
 
181
#endif /* SQUID_SRC_SSL_PEERCONNECTOR_H */
267
182