Mutual authentication with Tomcat 7

后端 未结 4 1449
醉话见心
醉话见心 2020-12-07 21:28

I\'m trying to set up a Java web service running in Tomcat 7 to use mutual (2-way) authentication. It seems like no matter what I do, connecting to the service on the secur

4条回答
  •  长情又很酷
    2020-12-07 22:01

    I would try the following steps

    1. Spool up container as you have configured on 8443.
    2. Run up your client application with -Djavax.net.debug=SSL

    That command will spool out PILES of information. What you need to check on that is that the server is presenting a list of CA's that it will accept for mutual authentication. If the listed CAs do not contain your certificate then the client will have no idea how to locate a match for the server.

    This can be made much easier using the openssl command 's_client'

    openssl s_client -connect localhost:8443 -showcerts
    

    That will format out some information that can be incalculable in their value of debugging this.

    If the server does not present a list of "acceptable" CAs you will have to do some magic when you produce your certificate set.

    Let me know what you find out and I can hopefully steer you in the right direction.

    OP added additional information

    Ok so the following is a bit of a problem for you:

    ---
    no peer certificate available
    ---
    No client certificate CA names sent
    ---
    SSL handshake has read 7 bytes and written 263 bytes
    ---
    

    Two things jump out immediately

    1. The server doesn't have a peer certificate
    2. There are no client CA names listed

    So for (1):

    1. make sure your keystore in fact does have the alias 'tomcat' in it using keytool.
    2. the store/key password stuff in tomcat is goofy. for sanity's sake, add both keystorePassword and keyPassword attributes to your connector with identical values. The documentation for Tomcat 7 indicates that the keystorePass will default to the keyPass if not set. If your keyPass and keystorePass are the same set the keyPass attribute only.

    Now for (2) we really need to have (1) working first - so get that up and running and we'll see where we are at that point.

提交回复
热议问题