apache - 具有与 Tomcat 的 AJP 连接的 Apache 网络服务器 - 请求对象中的 TLS 属性为空
问题描述
我们使用 Apache (2.4.41) 网络服务器作为 tomcat (8.5) 的反向代理,它运行一个自行实现的负载平衡器。Apache 网络服务器执行前端 TLS 工作并通过 AJP (mod_proxy_ajp) 与 tomcat 对话。在我们的负载均衡器中,我们使用 request.getAttributeNames() 来评估请求属性。一段时间以来,出现了具有以下键的空请求属性:
- org.apache.tomcat.util.net.secure_protocol_version
- javax.servlet.request.key_size
- javax.servlet.request.cipher_suite
- javax.servlet.request.ssl_session_id
我阅读了文档和源代码,但无法弄清楚为什么这些空属性仍然存在于请求中。根据 tomcat请求中 getAttributeNames() 的 javadoc,此方法不应获取大多数 TLS 特定属性:
/**
* Return the names of all request attributes for this Request, or an
* empty <code>Enumeration</code> if there are none. Note that the attribute
* names returned will only be those for the attributes set via
* {@link #setAttribute(String, Object)}. Tomcat internal attributes will
* not be included although they are accessible via
* {@link #getAttribute(String)}. The Tomcat internal attributes include:
* <ul>
* <li>{@link Globals#DISPATCHER_TYPE_ATTR}</li>
* <li>{@link Globals#DISPATCHER_REQUEST_PATH_ATTR}</li>
* <li>{@link Globals#ASYNC_SUPPORTED_ATTR}</li>
* <li>{@link Globals#CERTIFICATES_ATTR} (SSL connections only)</li>
* <li>{@link Globals#CIPHER_SUITE_ATTR} (SSL connections only)</li>
* <li>{@link Globals#KEY_SIZE_ATTR} (SSL connections only)</li>
* <li>{@link Globals#SSL_SESSION_ID_ATTR} (SSL connections only)</li>
* <li>{@link Globals#SSL_SESSION_MGR_ATTR} (SSL connections only)</li>
* <li>{@link Globals#PARAMETER_PARSE_FAILED_ATTR}</li>
* </ul>
* The underlying connector may also expose request attributes. These all
* have names starting with "org.apache.tomcat" and include:
* <ul>
* <li>{@link Globals#SENDFILE_SUPPORTED_ATTR}</li>
* </ul>
* Connector implementations may return some, all or none of these
* attributes and may also support additional attributes.
*
* @return the attribute names enumeration
*/
@Override
public Enumeration<String> getAttributeNames() {
也许有些人可以对此有所了解。提前致谢!
解决方案
Javadoc 并不完全正确:正如您在引用的源代码中看到的那样,除非您已经调用其中之一,否则getAttributeNames
不会列出这些内部属性:getAttribute
if (!sslAttributesParsed && TLSUtil.isTLSRequestAttribute(name)) {
coyoteRequest.action(ActionCode.REQ_SSL_ATTRIBUTE, coyoteRequest);
attr = coyoteRequest.getAttribute(Globals.CERTIFICATES_ATTR);
if (attr != null) {
attributes.put(Globals.CERTIFICATES_ATTR, attr);
}
attr = coyoteRequest.getAttribute(Globals.CIPHER_SUITE_ATTR);
if (attr != null) {
attributes.put(Globals.CIPHER_SUITE_ATTR, attr);
}
...
推荐阅读
- java - 位置管理器的 AddGpsStatusListener 在 android 10 中不起作用
- ruby-on-rails - Rails 不通过 Accepts_nested_attributes_for 保存图像
- python - 从网页上抓取表格标签
- angular - 离子(Angular)警报处理程序方法调用了两次
- javascript - 如何为选择标签内的选项元素添加鼠标悬停事件?
- android - 我应该如何实施 RadioGroup?
- javascript - 使用 CORS 访问其他站点 cookie
- java - 从数组中查找奇数或偶数并将值插入所需的数组。没有得到想要的输出
- django - 覆盖 Django LoginView
- php - 动态博客在本地工作,但在服务器博客页面上显示显示 http 错误 500