concept private key in category spring

appears as: private key, private keys
Spring Security in Action

This is an excerpt from Manning's book Spring Security in Action.

I would also like to bring to your attention the data storage. Data at rest adds to the responsibility of the application. Your app shouldn’t store all its data in a readable format. The application sometimes needs either to keep the data encrypted with a private key, or hashed. Secrets, like credentials and private keys, can also be considered data at rest. They should be carefully stored, usually in a secrets vault.

First, what is an asymmetric key pair, and how does it work? The concept is quite simple: An asymmetric key pair has two keys: one of them is called the private key, and the other is called the public key. The Authorization Server uses the private key to sign the tokens. One can sign the tokens only by using the private key (figure 15.5).

Figure 15.5 To sign the token, one needs to use the private key. The public key of the key pair would then be used by anyone to verify the identity of the signer.

The public key is linked to the private key, and this is why we call it a pair. But the public key can only be used to validate the signature. One cannot sign the token using the public key (figure 15.6).

In the application.properties file I store the name of the file, the alias of the key, and the password I used to protect the private key when I generated the password. We need these details to configure the JwtTokenStore. The next code snippet shows you the contents of my application.properties file.

password=ssia123
privateKey=ssia.jks
alias=ssia

Compared with the configurations we did for the Authorization Server to use a symmetric key, the only thing that changes is the definition of the JwtAccessTokenConverter object. We still use a JwtTokenStore, and you remember we’ve used the JwtAccessTokenConverter to configure the symmetric key in section 15.1. We’ll now use the same JwtAccessTokenConverter object to set up the private key. Listing 15.5 shows the configuration class of the Authorization Server.