configure tomcat for client authentication only for specific URL patterns

后端 未结 2 1699
一整个雨季
一整个雨季 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:10

    You can't do this in pure Tomcat. The best solution is to put an Apache HTTP in front of it, that terminates the SSL connection, and in which you can configure SSL to your heart's content right down to the level of an individual directory.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题