Java HTTPS client certificate authentication

后端 未结 9 1380
情深已故
情深已故 2020-11-22 07:42

I\'m fairly new to HTTPS/SSL/TLS and I\'m a bit confused over what exactly the clients are supposed to present when authenticating with certificates.

I\

9条回答
  •  臣服心动
    2020-11-22 08:06

    They JKS file is just a container for certificates and key pairs. In a client-side authentication scenario, the various parts of the keys will be located here:

    • The client's store will contain the client's private and public key pair. It is called a keystore.
    • The server's store will contain the client's public key. It is called a truststore.

    The separation of truststore and keystore is not mandatory but recommended. They can be the same physical file.

    To set the filesystem locations of the two stores, use the following system properties:

    -Djavax.net.ssl.keyStore=clientsidestore.jks
    

    and on the server:

    -Djavax.net.ssl.trustStore=serversidestore.jks
    

    To export the client's certificate (public key) to a file, so you can copy it to the server, use

    keytool -export -alias MYKEY -file publicclientkey.cer -store clientsidestore.jks
    

    To import the client's public key into the server's keystore, use (as the the poster mentioned, this has already been done by the server admins)

    keytool -import -file publicclientkey.cer -store serversidestore.jks
    

提交回复
热议问题