]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/ServerBump.cc
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / ssl / ServerBump.cc
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 /* DEBUG: section 33 Client-side Routines */
10
11 #include "squid.h"
12 #include "anyp/Uri.h"
13 #include "client_side.h"
14 #include "client_side_request.h"
15 #include "FwdState.h"
16 #include "http/Stream.h"
17 #include "ssl/ServerBump.h"
18 #include "Store.h"
19 #include "StoreClient.h"
20
21 CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump);
22
23 Ssl::ServerBump::ServerBump(ClientHttpRequest *http, StoreEntry *e, Ssl::BumpMode md):
24 step(XactionStep::tlsBump1)
25 {
26 assert(http->request);
27 request = http->request;
28 debugs(33, 4, "will peek at " << request->url.authority(true));
29 act.step1 = md;
30 act.step2 = act.step3 = Ssl::bumpNone;
31
32 if (e) {
33 entry = e;
34 entry->lock("Ssl::ServerBump");
35 } else {
36 // XXX: Performance regression. c_str() reallocates
37 SBuf uriBuf(request->effectiveRequestUri());
38 const char *uri = uriBuf.c_str();
39 entry = storeCreateEntry(uri, uri, request->flags, request->method);
40 }
41 // We do not need to be a client because the error contents will be used
42 // later, but an entry without any client will trim all its contents away.
43 sc = storeClientListAdd(entry, this);
44 #if USE_DELAY_POOLS
45 sc->setDelayId(DelayId::DelayClient(http));
46 #endif
47 }
48
49 Ssl::ServerBump::~ServerBump()
50 {
51 debugs(33, 4, HERE << "destroying");
52 if (entry) {
53 debugs(33, 4, HERE << *entry);
54 storeUnregister(sc, entry, this);
55 entry->unlock("Ssl::ServerBump");
56 }
57 }
58
59 void
60 Ssl::ServerBump::attachServerSession(const Security::SessionPointer &s)
61 {
62 if (serverSession)
63 return;
64
65 serverSession = s;
66 }
67
68 const Security::CertErrors *
69 Ssl::ServerBump::sslErrors() const
70 {
71 if (!serverSession)
72 return NULL;
73
74 const Security::CertErrors *errs = static_cast<const Security::CertErrors*>(SSL_get_ex_data(serverSession.get(), ssl_ex_index_ssl_errors));
75 return errs;
76 }
77