]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ssl/ServerBump.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / ssl / ServerBump.cc
CommitLineData
fd4624d7 1/*
bf95c10a 2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
fd4624d7 3 *
bbc27441
AJ
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.
fd4624d7
CT
7 */
8
bbc27441
AJ
9/* DEBUG: section 33 Client-side Routines */
10
fd4624d7 11#include "squid.h"
c8ab5ec6 12#include "anyp/Uri.h"
fd4624d7 13#include "client_side.h"
f5e17947 14#include "client_side_request.h"
eb13c21e 15#include "FwdState.h"
d3dddfb5 16#include "http/Stream.h"
fd4624d7
CT
17#include "ssl/ServerBump.h"
18#include "Store.h"
e87137f1 19#include "StoreClient.h"
fd4624d7
CT
20
21CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump);
22
f5e17947 23Ssl::ServerBump::ServerBump(ClientHttpRequest *http, StoreEntry *e, Ssl::BumpMode md):
090f1d3c 24 step(XactionStep::tlsBump1)
fd4624d7 25{
f5e17947
CT
26 assert(http->request);
27 request = http->request;
5c51bffb 28 debugs(33, 4, "will peek at " << request->url.authority(true));
a9c2dd2f
CT
29 act.step1 = md;
30 act.step2 = act.step3 = Ssl::bumpNone;
31
2bd84e5f
CT
32 if (e) {
33 entry = e;
1bfe9ade 34 entry->lock("Ssl::ServerBump");
851feda6
AJ
35 } else {
36 // XXX: Performance regression. c_str() reallocates
81e019a0
AR
37 SBuf uriBuf(request->effectiveRequestUri());
38 const char *uri = uriBuf.c_str();
39 entry = storeCreateEntry(uri, uri, request->flags, request->method);
851feda6 40 }
fd4624d7
CT
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);
f5e17947
CT
44#if USE_DELAY_POOLS
45 sc->setDelayId(DelayId::DelayClient(http));
46#endif
fd4624d7
CT
47}
48
49Ssl::ServerBump::~ServerBump()
50{
bf95c10a 51 debugs(33, 4, "destroying");
fd4624d7 52 if (entry) {
bf95c10a 53 debugs(33, 4, *entry);
fd4624d7 54 storeUnregister(sc, entry, this);
1bfe9ade 55 entry->unlock("Ssl::ServerBump");
fd4624d7 56 }
fd4624d7
CT
57}
58
088f0761 59void
8f917129 60Ssl::ServerBump::attachServerSession(const Security::SessionPointer &s)
088f0761 61{
8f917129 62 serverSession = s;
088f0761
CT
63}
64
92e3827b 65const Security::CertErrors *
088f0761
CT
66Ssl::ServerBump::sslErrors() const
67{
8f917129 68 if (!serverSession)
aee3523a 69 return nullptr;
088f0761 70
8f917129 71 const Security::CertErrors *errs = static_cast<const Security::CertErrors*>(SSL_get_ex_data(serverSession.get(), ssl_ex_index_ssl_errors));
088f0761
CT
72 return errs;
73}
cdc1926a 74