Using X.509 security mechanism for Securing Spring REST api with Spring Boot and Spring Security. You can find these three directories. Contains the already generated keyStores, trustStores and certificates for both client and server. Jul 17, 2018  Implementing JWT Authentication on Spring Boot APIs. Let's learn the correct way to secure Spring Boot RESTful APIs with JWTs.

using X.509 security mechanism for Securing Spring REST api with Spring Boot and Spring Security

How to Run

You can find these three directories.

1. keystores

Contains the already generated keyStores, trustStores and certificates for both client and server.

2. spring-boot-security-x509-server-app

Server application that contains the REST api. Generate rs256 public key from key file. this application will support for the X.509 Authentication. This application will run in HTTPS.

3. spring-boot-security-x509-client-app

Client application that calls the REST api offered by the server app by proving a valid certificate.

Projects modules/directories in detailed .

1. keystores

This directory contains the generated keystores, truststores and certificates for both server application and client application.if you need you can use these generated artifacts for running this app. otherwise you can create your own set using following commands.

Go to any directory where you need to create these files and execute following commands.(alternatively you can change the path name of the files without going to any directory)

e.g:- keytool -genkey -alias serverkey -keystore <pathToServerKeyStore> -keyalg RSA -storetype PKCS12
1) Generate server key and self signed server certificate
Api
2) Generate client key and self signed client certificate
3) Export the server certificate
4) Export the client certificate
5) Import the server certificate into client truststore
6) Import the client certificate into server truststore

Generate An Api Key For Authentication In Spring Boot 2017

Now you have created the client certificate, server certifcate and associate them with the relevant truststores and keystores. it is time to run client and server apps and see the output.

2. spring-boot-security-x509-server-app

This is the server application which offer the REST service. Only the trusted client with the valid certificate can only acccess the server application.check the server keystore and truststore paths and passwords are properly defined. Server app should be run on HTTPS protocol.

spring-boot-security-x509-server-app/src/main/resources/application.properties

Generate An Api Key For Authentication In Spring Boot Windows 7

build and run server app in the spring-boot embedded tomcat serverBuild App :- mvn clean install
Run App:- java -jar target/spring-boot-security-x509-server-app-0.0.1-SNAPSHOT.jar

You can be access through the following URL. but you cannot access it with your web browser as your web browser does not have the client certificate we have created for accessing the server app.

Generate An Api Key For Authentication In Spring Boot Download

3. spring-boot-security-x509-client-app

This is the client application that we are accessing through the browser. Client application will invoke th REST api service offered by the server application and display the retrieved output. Since the server application requires X.509 authentication, client needs to verify the server certificate and needs to send its ceritifate for the server to authenticate client's identity. for these reasons client should have the access to the clientKeystore and clientTrustStore. So check whther both of those are properly defined in the application.

RestClient.javaEaseus data recovery wizard trial license key generator.

Facebook messenger free download for mobile phone. Then build and run the application as follows. if you need you can change the server port in application.properties

Generate An Api Key For Authentication In Spring Boot Camp

Build App :- mvn clean install
Run App:- java -jar target/spring-boot-security-x509-server-app-0.0.1-SNAPSHOT.jar

Generate An Api Key For Authentication In Spring Boot 2017

Now You can load the above URL in your browser and see the output.We have done with x.509 Authentication with Spring Boot and Spring Security.

Coments are closed
Scroll to top