fail(anErr);
} // else use actual error from last connection attempt
#if USE_SSL
- if (request->protocol == AnyP::PROTO_SSL_PEEK && request->clientConnectionManager.valid()) {
+ if (request->flags.sslPeek && request->clientConnectionManager.valid()) {
errorAppendEntry(entry, err); // will free err
err = NULL;
CallJobHere1(17, 4, request->clientConnectionManager, ConnStateData,
request->clientConnectionManager->setBumpSslErrorList(errNoList);
}
- HttpRequest *fakeRequest = NULL;
- if (request->protocol == AnyP::PROTO_SSL_PEEK && srvX509 != NULL) {
- // Create a fake request, with HTTPS protocol and host name the CN name from
- // server certificate if exist, to provide a more user friendly URL on error page
- fakeRequest = request->clone();
- fakeRequest->protocol = AnyP::PROTO_HTTPS;
- safe_free(fakeRequest->canonical); // force re-build url canonical
- const char *name = Ssl::CommonHostName(srvX509);
- if (name)
- fakeRequest->SetHost(name);
-
- debugs(83, 3, HERE << "Created a fake request for " <<
- urlCanonical(fakeRequest) << " with " <<
- fakeRequest->GetHost() << " hostname");
+ if (request->flags.sslPeek) {
+ // If possible, set host name to server certificate CN.
+ if (srvX509) {
+ if (const char *name = Ssl::CommonHostName(srvX509)) {
+ request->SetHost(name);
+ debugs(83, 3, HERE << "reset request host: " << name);
+ }
+ }
}
- ErrorState *const anErr = makeConnectingError(ERR_SECURE_CONNECT_FAIL, fakeRequest);
+ ErrorState *const anErr = makeConnectingError(ERR_SECURE_CONNECT_FAIL);
anErr->xerrno = sysErrNo;
anErr->detail = errDetails;
fail(anErr);
SSL_set_session(ssl, peer->sslSession);
} else {
- if (request->protocol != AnyP::PROTO_SSL_PEEK)
- SSL_set_ex_data(ssl, ssl_ex_index_server, (void*)request->GetHost());
- // else we do not have the ssl server name yet, but only its IP address.
-
- // We need to set SNI TLS extension only in the case we are
- // connecting direct to origin server
- Ssl::setClientSNI(ssl, request->GetHost());
+ // While we are peeking at the certificate, we do not know the server
+ // name that the client will request (after interception or CONNECT).
+ if (!request->flags.sslPeek) {
+ const char *hostname = request->GetHost();
+ SSL_set_ex_data(ssl, ssl_ex_index_server, (void*)hostname);
+
+ // Use SNI TLS extension only when we connect directly
+ // to the origin server and we know the server host name
+ if (!request->GetHostIsNumeric())
+ Ssl::setClientSNI(ssl, hostname);
+ }
}
// Create the ACL check list now, while we have access to more info.
#if USE_SSL
if ((serverConnection()->getPeer() && serverConnection()->getPeer()->use_ssl) ||
- (!serverConnection()->getPeer() &&
- (request->protocol == AnyP::PROTO_HTTPS || request->protocol == AnyP::PROTO_SSL_PEEK))) {
+ (!serverConnection()->getPeer() && request->protocol == AnyP::PROTO_HTTPS)) {
initiateSSL();
return;
}
#endif
#if USE_SSL
- if (request->protocol == AnyP::PROTO_SSL_PEEK) {
+ if (request->flags.sslPeek) {
CallJobHere1(17, 4, request->clientConnectionManager, ConnStateData,
ConnStateData::httpsPeeked, serverConnection());
unregister(serverConn); // async call owns it now
request->peer_domain = serverConnection()->getPeer()->domain;
httpStart(this);
} else {
+ assert(!request->flags.sslPeek);
request->peer_login = NULL;
request->peer_domain = NULL;
case AnyP::PROTO_INTERNAL:
-#if USE_SSL
- case AnyP::PROTO_SSL_PEEK:
-#endif
-
case AnyP::PROTO_URN:
fatal_dump("Should never get here");
break;
* proxy-revalidate, must-revalidate or s-maxage Cache-Control directive.
*/
ErrorState *
-FwdState::makeConnectingError(const err_type type, HttpRequest *useRequest) const
+FwdState::makeConnectingError(const err_type type) const
{
return errorCon(type, request->flags.need_validation ?
- HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, useRequest != NULL? useRequest : request);
+ HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
}
static void
struct request_flags {
- request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),fail_on_validation_err(0),stale_if_hit(0),accelerated(0),ignore_cc(0),intercepted(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),sslBumped(0),destinationIPLookedUp_(0) {
+ request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),fail_on_validation_err(0),stale_if_hit(0),accelerated(0),ignore_cc(0),intercepted(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),sslPeek(0),sslBumped(0),destinationIPLookedUp_(0) {
#if USE_HTTP_VIOLATIONS
nocache_hack = 0;
#endif
unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
unsigned int stream_error:1; /**< Whether stream error has occured */
+ unsigned int sslPeek:1; ///< internal ssl-bump request to get server cert
unsigned int sslBumped:1; /**< ssl-bumped request*/
// When adding new flags, please update cloneAdaptationImmune() as needed.