Sign inSign up

deepaksorthiya/spring-boot-ssl-client-server

By deepaksorthiya

Updated 10 months ago

Spring Boot SSL using PKCS12 JKS and PEM format

Image
Languages & frameworks
0

2.5K

deepaksorthiya/spring-boot-ssl-client-server repository overview

Java Maven Build Test

** Spring Boot SSL using PKCS12 JKS and PEM format **

Getting Started

Requirements:

Git: 2.51+
Spring Boot: 3.5.7
Maven: 3.9+
Java: 25
Docker Desktop(Optional): Tested on 4.47.0

(Optional)Generate PKCS/JKS/PEM files

Required files are already in class path. If you want to generate your own self-signed then use below commands. generate PKCS12 file

keytool -genkeypair -alias springbootssl -keyalg RSA -keysize 4096 -storetype PKCS12 -keystore springbootssl.p12 -validity 36500

generate JKS file from PKCS12

keytool -importkeystore -srckeystore springbootssl.p12 -srcstoretype pkcs12 -destkeystore springbootssl.jks -deststoretype jks

generate private key and certificate file

openssl req -x509 -subj "/CN=localhost" -keyout private.key -out certificate.crt -sha256 -days 36500 -nodes -newkey rsa

for windows OS

openssl req -x509 -subj "//CN=localhost" -keyout private.key -out certificate.crt -sha256 -days 36500 -nodes -newkey rsa

Clone this repository:

git clone https://github.com/deepaksorthiya/spring-boot-ssl-client-server.git
cd spring-boot-ssl-client-server

Pre-requisite Configuration

check file application.properties. this file contains PKCS12 and PEM based ssl config.

Build Project and Run Test Cases:

./mvnw clean package
Run Project:
./mvnw spring-boot:run

(Optional)Run Using Docker(docker should be running)

Build Docker Image
./mvnw clean spring-boot:build-image -DskipTests

OR

docker build -t deepaksorthiya/spring-boot-ssl-client-server:0.0.1-SNAPSHOT . 
Run Docker Image
docker run --name spring-boot-ssl-client-server -p 8080:8080 deepaksorthiya/spring-boot-ssl-client-server:0.0.1-SNAPSHOT

Testing

curl -v -k https://localhost:8443/server-call
curl -v -k https://localhost:8443/client-call

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Maven Parent overrides

Due to Maven's design, elements are inherited from the parent POM to the project POM. While most of the inheritance is fine, it also inherits unwanted elements like <license> and <developers> from the parent. To prevent this, the project POM contains empty overrides for these elements. If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides.

Tag summary

Content type

Image

Digest

sha256:27700c511

Size

34.6 MB

Last updated

10 months ago

docker pull deepaksorthiya/spring-boot-ssl-client-server