MCPcopy Create free account
hub / github.com/apache/trafficserver / SslHdrExpand

Function SslHdrExpand

plugins/experimental/sslheaders/sslheaders.cc:174–217  ·  view source on GitHub ↗

Process SSL header expansions. If this is not an SSL connection, then we need to delete the SSL headers so that malicious clients cannot inject bogus information. Otherwise, we populate the header with the expanded value. If the value expands to something empty, we nuke the header.

Source from the content-addressed store, hash-verified

172// so that malicious clients cannot inject bogus information. Otherwise, we populate the header with the
173// expanded value. If the value expands to something empty, we nuke the header.
174static void
175SslHdrExpand(SSL *ssl, const SslHdrInstance::expansion_list &expansions, TSMBuffer mbuf, TSMLoc mhdr)
176{
177 if (ssl == nullptr) {
178 for (const auto &expansion : expansions) {
179 SslHdrRemoveHeader(mbuf, mhdr, expansion.name);
180 }
181 } else {
182 WrapX509<true> clientX509(ssl);
183 WrapX509<false> serverX509(ssl);
184 X509 *x509;
185
186 BIO *exp = BIO_new(BIO_s_mem());
187
188 for (const auto &expansion : expansions) {
189 switch (expansion.scope) {
190 case SSL_HEADERS_SCOPE_CLIENT:
191 x509 = clientX509.get();
192 if (x509 == nullptr) {
193 SslHdrRemoveHeader(mbuf, mhdr, expansion.name);
194 continue;
195 }
196 break;
197 case SSL_HEADERS_SCOPE_SERVER:
198 x509 = serverX509.get();
199 if (x509 == nullptr) {
200 continue;
201 }
202 break;
203 default:
204 continue;
205 }
206
207 SslHdrExpandX509Field(exp, x509, expansion.field);
208 if (BIO_pending(exp)) {
209 SslHdrSetHeader(mbuf, mhdr, expansion.name, exp);
210 } else {
211 SslHdrRemoveHeader(mbuf, mhdr, expansion.name);
212 }
213 }
214
215 BIO_free(exp);
216 }
217}
218
219static SslHdrInstance *
220SslHdrParseOptions(int argc, const char **argv)

Callers 1

SslHdrExpandRequestHookFunction · 0.85

Calls 4

SslHdrRemoveHeaderFunction · 0.85
SslHdrExpandX509FieldFunction · 0.85
SslHdrSetHeaderFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected