configure tomcat for client authentication only for specific URL patterns

后端 未结 2 1701
一整个雨季
一整个雨季 2021-01-21 15:25

I have an application with a few war files all deployed on the same tomcat server. I need to force client authentication only for one war context, and only for a specific URL.

2条回答
  •  心在旅途
    2021-01-21 16:26

    If you want to accept any certificate from trusted CAs, just put clientAuth="want" to Connector and write a filter to check, if a certificate was sent. Assign that filter to desired web app only. In the filter, get the certificate using:

    request.getAttribute("javax.servlet.request.X509Certificate");
    

    and check it's CA.

    But remember, that any certificate from that CA will allow access. If this is a public CA, anyone can buy one and access your app. You should always check the DN, in Tomcat you do this by defining a user, or manually in a filter.

提交回复
热议问题