]>
Commit | Line | Data |
---|---|---|
fd4624d7 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 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 CT |
11 | #include "squid.h" |
12 | ||
13 | #include "client_side.h" | |
eb13c21e | 14 | #include "FwdState.h" |
d3dddfb5 | 15 | #include "http/Stream.h" |
fd4624d7 CT |
16 | #include "ssl/ServerBump.h" |
17 | #include "Store.h" | |
e87137f1 | 18 | #include "StoreClient.h" |
b1bd952a | 19 | #include "URL.h" |
fd4624d7 CT |
20 | |
21 | CBDATA_NAMESPACED_CLASS_INIT(Ssl, ServerBump); | |
22 | ||
d620ae0e | 23 | Ssl::ServerBump::ServerBump(HttpRequest *fakeRequest, StoreEntry *e, Ssl::BumpMode md): |
f53969cc | 24 | request(fakeRequest), |
f53969cc | 25 | step(bumpStep1) |
fd4624d7 | 26 | { |
5c51bffb | 27 | debugs(33, 4, "will peek at " << request->url.authority(true)); |
a9c2dd2f CT |
28 | act.step1 = md; |
29 | act.step2 = act.step3 = Ssl::bumpNone; | |
30 | ||
2bd84e5f CT |
31 | if (e) { |
32 | entry = e; | |
1bfe9ade | 33 | entry->lock("Ssl::ServerBump"); |
851feda6 AJ |
34 | } else { |
35 | // XXX: Performance regression. c_str() reallocates | |
81e019a0 AR |
36 | SBuf uriBuf(request->effectiveRequestUri()); |
37 | const char *uri = uriBuf.c_str(); | |
38 | entry = storeCreateEntry(uri, uri, request->flags, request->method); | |
851feda6 | 39 | } |
fd4624d7 CT |
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); | |
1bfe9ade | 51 | entry->unlock("Ssl::ServerBump"); |
fd4624d7 | 52 | } |
fd4624d7 CT |
53 | } |
54 | ||
088f0761 | 55 | void |
8f917129 | 56 | Ssl::ServerBump::attachServerSession(const Security::SessionPointer &s) |
088f0761 | 57 | { |
8f917129 | 58 | if (serverSession) |
088f0761 CT |
59 | return; |
60 | ||
8f917129 | 61 | serverSession = s; |
088f0761 CT |
62 | } |
63 | ||
92e3827b | 64 | const Security::CertErrors * |
088f0761 CT |
65 | Ssl::ServerBump::sslErrors() const |
66 | { | |
8f917129 | 67 | if (!serverSession) |
088f0761 CT |
68 | return NULL; |
69 | ||
8f917129 | 70 | const Security::CertErrors *errs = static_cast<const Security::CertErrors*>(SSL_get_ex_data(serverSession.get(), ssl_ex_index_ssl_errors)); |
088f0761 CT |
71 | return errs; |
72 | } | |
cdc1926a | 73 |