]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/ServerBump.cc
86e954a51ccad8dfc5ff1ea3c386bd3f1ee8c153
[thirdparty/squid.git] / src / ssl / ServerBump.cc
1 /*
2 * Copyright (C) 1996-2016 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
13 #include "client_side.h"
14 #include "FwdState.h"
15 #include "http/Stream.h"
16 #include "ssl/ServerBump.h"
17 #include "Store.h"
18 #include "StoreClient.h"
19 #include "URL.h"
20
21 CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump);
22
23 Ssl::ServerBump::ServerBump(HttpRequest *fakeRequest, StoreEntry *e, Ssl::BumpMode md):
24 request(fakeRequest),
25 step(bumpStep1)
26 {
27 debugs(33, 4, "will peek at " << request->url.authority(true));
28 act.step1 = md;
29 act.step2 = act.step3 = Ssl::bumpNone;
30
31 if (e) {
32 entry = e;
33 entry->lock("Ssl::ServerBump");
34 } else {
35 // XXX: Performance regression. c_str() reallocates
36 SBuf uriBuf(request->effectiveRequestUri());
37 const char *uri = uriBuf.c_str();
38 entry = storeCreateEntry(uri, uri, request->flags, request->method);
39 }
40 // We do not need to be a client because the error contents will be used
41 // later, but an entry without any client will trim all its contents away.
42 sc = storeClientListAdd(entry, this);
43 }
44
45 Ssl::ServerBump::~ServerBump()
46 {
47 debugs(33, 4, HERE << "destroying");
48 if (entry) {
49 debugs(33, 4, HERE << *entry);
50 storeUnregister(sc, entry, this);
51 entry->unlock("Ssl::ServerBump");
52 }
53 }
54
55 void
56 Ssl::ServerBump::attachServerSession(const Security::SessionPointer &s)
57 {
58 if (serverSession)
59 return;
60
61 serverSession = s;
62 }
63
64 const Security::CertErrors *
65 Ssl::ServerBump::sslErrors() const
66 {
67 if (!serverSession)
68 return NULL;
69
70 const Security::CertErrors *errs = static_cast<const Security::CertErrors*>(SSL_get_ex_data(serverSession.get(), ssl_ex_index_ssl_errors));
71 return errs;
72 }
73