我正在尝试使Tomcat Web应用程序对传入连接使用客户端证书身份验证.在server.xml中使用clientAuth = true时,一切正常,但由于在同一服务器上运行的其他应用程序,我们无法在生产环境中使用它.
有没有办法形成一个web.xml文档,以便它以与clientAuth = true相同的方式强制应用程序的客户端证书使用?似乎使用CLIENT-CERT设置还要求您为每个要访问系统的证书设置tomcat用户帐户?我们需要能够允许来自指定CA(在服务器信任库中设置)的所有证书,其中主题与特定规则匹配(在实际应用程序中检查).我希望以下的东西能起作用,但还没有运气!
<security-constraint>
<web-resource-collection>
<web-resource-name>Everything</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>CLIENT-CERT</auth-method>
</login-config>
Run Code Online (Sandbox Code Playgroud) 我一直在写一些东西来读取来自传入的HttpServletRequest(下面的'request')的请求流(包含gzip压缩数据),但看起来普通的InputStream读取方法实际上并没有读取所有内容?
我的代码是:
InputStream requestStream = request.getInputStream();
if ((length = request.getContentLength()) != -1)
{
received = new byte[length];
requestStream.read(received, 0, length);
}
else
{
// create a variable length list of bytes
List<Byte> bytes = new ArrayList<Byte>();
boolean endLoop = false;
while (!endLoop)
{
// try and read the next value from the stream.. if not -1, add it to the list as a byte. if
// it is, we've reached the end.
int currentByte = requestStream.read();
if (currentByte != -1) …Run Code Online (Sandbox Code Playgroud)